rails_modal_manager 1.0.11 → 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: d269701f2b02e0fdfff0588481955d72e01a4bf9482ee6490fa4cfafa16d8485
4
- data.tar.gz: 24b240b6fe17cd7a3b10aa645b345fb53627c4549dc6f2fdd5123004fad48ef0
3
+ metadata.gz: 3aef02a89c60f4390647bdb318057751ef19caea49b2849ab1af859412267d54
4
+ data.tar.gz: aafa0a2b8165398b4f91dcb5ea3e3b013433550b227a0c6e0a5df9c6f2840b15
5
5
  SHA512:
6
- metadata.gz: 02c3088c03fe707a6bf7281d0c9e2efc659a0e0f3ca6cc72740908b0530d6198686b74b6004fc4dff47f9aba20b81a967b675b12a6c676f37d08d164ed51916b
7
- data.tar.gz: aad4172168208e0c032782497b73b549e90bd352dcd3558c1ca8a0a33f55ad5dae0204b75b4edf3fb18c007ffe72c2caf93c73af6c33960327c8056c645af30a
6
+ metadata.gz: f5e26d4b12715b984126fa2a4262a56e9f23a238fdc68c5c89c7179c159b7abb36fe93cb789be1f834ba51d720ace3bf66f24aa4a65266433ab166f8b30f68ad
7
+ data.tar.gz: af75896852ef1fc10956a6b8d305da635e074655dff95082234999de0b43ff379b58c22e5d39190007e28858af0e14819f57a67177de7841a34200c779491d5c
data/README.md CHANGED
@@ -3,7 +3,7 @@
3
3
  Rails 애플리케이션을 위한 고급 모달 매니저입니다.
4
4
  `@reshacs/react-modal-manager`에서 포팅되었습니다.
5
5
 
6
- **Version:** 1.0.11
6
+ **Version:** 1.0.12
7
7
 
8
8
  ---
9
9
 
@@ -789,6 +789,10 @@ MIT License
789
789
 
790
790
  ## 변경 이력
791
791
 
792
+ ### v1.0.12
793
+
794
+ - **최소화된 모달 자동 복원**: `openModal()` 호출 시 해당 모달이 이미 열려있고 최소화된 상태라면 자동으로 복원되도록 개선
795
+
792
796
  ### v1.0.11
793
797
 
794
798
  - **사이드바-서브메뉴 AJAX 연동 개선**: 사이드바 메뉴 전환 시 활성화된 서브메뉴의 콘텐츠가 자동으로 로드되도록 개선
@@ -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
- return document.getElementById(`${this.effectiveModalId}-overlay`)
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) {
@@ -80,14 +80,24 @@ export function initGlobalClickHandler() {
80
80
 
81
81
  /**
82
82
  * Open a modal by ID
83
+ * If the modal is already open but minimized, it will be restored instead
83
84
  * @param {string} modalId - The modal's ID
84
85
  */
85
86
  export function openModal(modalId) {
86
87
  const modalElement = document.getElementById(modalId)
87
- if (modalElement) {
88
- modalElement.setAttribute('data-rmm-modal-open-value', 'true')
89
- modalElement.dispatchEvent(new CustomEvent('rmm:open'))
88
+ if (!modalElement) return
89
+
90
+ // Check if the modal is already open and minimized
91
+ const config = modalStore.getModalConfig(modalId)
92
+ if (config && config.isMinimized) {
93
+ // Restore the minimized modal
94
+ modalStore.restoreModalGroup(modalId)
95
+ return
90
96
  }
97
+
98
+ // Open the modal normally
99
+ modalElement.setAttribute('data-rmm-modal-open-value', 'true')
100
+ modalElement.dispatchEvent(new CustomEvent('rmm:open'))
91
101
  }
92
102
 
93
103
  /**
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RailsModalManager
4
- VERSION = "1.0.11"
4
+ VERSION = "1.0.13"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails_modal_manager
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.11
4
+ version: 1.0.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - reshacs