rails_modal_manager 1.0.12 → 1.0.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 3aef02a89c60f4390647bdb318057751ef19caea49b2849ab1af859412267d54
|
|
4
|
+
data.tar.gz: aafa0a2b8165398b4f91dcb5ea3e3b013433550b227a0c6e0a5df9c6f2840b15
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: f5e26d4b12715b984126fa2a4262a56e9f23a238fdc68c5c89c7179c159b7abb36fe93cb789be1f834ba51d720ace3bf66f24aa4a65266433ab166f8b30f68ad
|
|
7
|
+
data.tar.gz: af75896852ef1fc10956a6b8d305da635e074655dff95082234999de0b43ff379b58c22e5d39190007e28858af0e14819f57a67177de7841a34200c779491d5c
|
|
@@ -147,6 +147,9 @@ export default class extends Controller {
|
|
|
147
147
|
// Register close callback
|
|
148
148
|
modalStore.registerCloseCallback(modalId, () => this.close('programmatic'))
|
|
149
149
|
|
|
150
|
+
// Move to persistent container (outside Turbo Frame) to survive navigation
|
|
151
|
+
this.moveToChildModalsContainer()
|
|
152
|
+
|
|
150
153
|
// Add to history stack
|
|
151
154
|
if (this.enableHistoryStackValue && !historyStackManager.hasHisData('modal', modalId)) {
|
|
152
155
|
historyStackManager.addHisData('modal', modalId, () => this.close('history'))
|
|
@@ -682,9 +685,48 @@ export default class extends Controller {
|
|
|
682
685
|
historyStackManager.removeMultipleHisData('modal', allModalIds)
|
|
683
686
|
}
|
|
684
687
|
|
|
688
|
+
// Move modal DOM to persistent container (outside Turbo Frame)
|
|
689
|
+
// This ensures minimized modals survive Turbo Frame navigation
|
|
690
|
+
this.moveToChildModalsContainer()
|
|
691
|
+
|
|
685
692
|
this.dispatch('minimize', { detail: { modalId: modalId } })
|
|
686
693
|
}
|
|
687
694
|
|
|
695
|
+
/**
|
|
696
|
+
* Move modal (with wrapper if exists) to #child-modals-container
|
|
697
|
+
* This prevents DOM removal when Turbo Frame content is replaced
|
|
698
|
+
*/
|
|
699
|
+
moveToChildModalsContainer() {
|
|
700
|
+
const container = document.getElementById('child-modals-container')
|
|
701
|
+
if (!container) return
|
|
702
|
+
|
|
703
|
+
const overlay = this.getOverlay()
|
|
704
|
+
const parent = this.element.parentElement
|
|
705
|
+
|
|
706
|
+
// Determine what to move: wrapper (if exists) or just modal
|
|
707
|
+
let elementToMove = this.element
|
|
708
|
+
|
|
709
|
+
// Check if parent is a wrapper (has data-controller and is not body/frame/container)
|
|
710
|
+
if (parent &&
|
|
711
|
+
parent.dataset.controller &&
|
|
712
|
+
parent.id !== 'child-modals-container' &&
|
|
713
|
+
parent.tagName !== 'TURBO-FRAME' &&
|
|
714
|
+
parent.tagName !== 'BODY') {
|
|
715
|
+
elementToMove = parent
|
|
716
|
+
}
|
|
717
|
+
|
|
718
|
+
// Skip if already in container
|
|
719
|
+
if (elementToMove.parentElement === container) return
|
|
720
|
+
|
|
721
|
+
// If overlay is outside the element to move, move it first
|
|
722
|
+
if (overlay && !elementToMove.contains(overlay) && overlay.parentElement !== container) {
|
|
723
|
+
container.appendChild(overlay)
|
|
724
|
+
}
|
|
725
|
+
|
|
726
|
+
// Move the element (modal or wrapper including overlay)
|
|
727
|
+
container.appendChild(elementToMove)
|
|
728
|
+
}
|
|
729
|
+
|
|
688
730
|
maximize() {
|
|
689
731
|
const modalId = this.effectiveModalId
|
|
690
732
|
const config = modalStore.getModalConfig(modalId)
|
|
@@ -777,7 +819,18 @@ export default class extends Controller {
|
|
|
777
819
|
// ============================================
|
|
778
820
|
|
|
779
821
|
getOverlay() {
|
|
780
|
-
|
|
822
|
+
const overlayId = `${this.effectiveModalId}-overlay`
|
|
823
|
+
|
|
824
|
+
// If this modal is inside child-modals-container, search there first
|
|
825
|
+
// This prevents finding duplicate overlays in turbo-frame
|
|
826
|
+
const container = document.getElementById('child-modals-container')
|
|
827
|
+
if (container && container.contains(this.element)) {
|
|
828
|
+
const overlayInContainer = container.querySelector(`#${overlayId}`)
|
|
829
|
+
if (overlayInContainer) return overlayInContainer
|
|
830
|
+
}
|
|
831
|
+
|
|
832
|
+
// Fallback to document-level search
|
|
833
|
+
return document.getElementById(overlayId)
|
|
781
834
|
}
|
|
782
835
|
|
|
783
836
|
hasAttribute(attr) {
|