rails_modal_manager 1.0.2 → 1.0.4

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: 0c80e8d7e55dbbb87e5b24b9122044cb93d284bf159e8138398a23af0cd6fac0
4
- data.tar.gz: 1748af12fd89406a1a4e0e63fca0b80175d997129c0fbb0f06fba156904171e3
3
+ metadata.gz: c2f67902f2a1a7d3f98a0318b84ebd2adeeec5d1d8067ead263ea394fc76d64a
4
+ data.tar.gz: 88ab650eaaf8eb145a1fe7844dec22acf2e0e61381e2e1217ee172fea6bee283
5
5
  SHA512:
6
- metadata.gz: 938947f91cbd5a5b52073f9978af5f74e48c40cfeac1f6962b0168e8ce59ba23ce128f63d10f26cc4b14584de5133b723fafdefaace79add387607add887ab77
7
- data.tar.gz: b5f928084038eef28bf702b65a5064a576b63bf667a09254cc7a540ab919bf45bd09f5fc4af9373b7cc6e18e3b0715bd3f98891144c733b0b5ba25fa8495518a
6
+ metadata.gz: 120b2415ca136f031f10805151f948e6616754c2e6c07c303fb115f9f87f56f66037688f93fbfd95398a3612d79f84f0c398e006654f434222b5304cfb1fa3d8
7
+ data.tar.gz: 29edd0abdbc5cf321eb818366a86998e18cdc3dce2b39cf37e5a4ba75866224e8b8750adbc32548167ddefa217302a86a518de6610eeb6dbe659b397791cb063
@@ -35,10 +35,10 @@ module RailsModalManager
35
35
  # <% end %>
36
36
  #
37
37
  def rmm_modal(modal_id, options = {}, &block)
38
+ content = block_given? ? capture(&block) : nil
38
39
  render(
39
40
  partial: "rails_modal_manager/modal",
40
- locals: options.merge(modal_id: modal_id),
41
- &block
41
+ locals: options.merge(modal_id: modal_id, block_content: content)
42
42
  )
43
43
  end
44
44
 
@@ -90,7 +90,7 @@ export default class extends Controller {
90
90
  openValueChanged(value, previousValue) {
91
91
  if (value && !previousValue) {
92
92
  this.open()
93
- } else if (!value && previousValue) {
93
+ } else if (!value && previousValue && !this._closingProgrammatically) {
94
94
  this.close('programmatic')
95
95
  }
96
96
  }
@@ -347,6 +347,12 @@ export default class extends Controller {
347
347
  if (overlay) overlay.classList.remove('rmm-active')
348
348
 
349
349
  setTimeout(() => {
350
+ // Reset openValue to false so modal can be reopened
351
+ // Use a flag to prevent openValueChanged from triggering close again
352
+ this._closingProgrammatically = true
353
+ this.openValue = false
354
+ this._closingProgrammatically = false
355
+
350
356
  if (callback) callback()
351
357
  }, this.animationDurationValue)
352
358
  }
@@ -3,12 +3,12 @@
3
3
  * Full-featured modal manager for Rails applications
4
4
  * Ported from @reshacs/react-modal-manager
5
5
  *
6
- * @version 1.0.2
6
+ * @version 1.0.3
7
7
  * @author reshacs
8
8
  * @license MIT
9
9
  */
10
10
 
11
- export const VERSION = "1.0.2"
11
+ export const VERSION = "1.0.3"
12
12
 
13
13
  // Import core modules for internal use
14
14
  import modalStore, { MODAL_CONSTANTS, SIZE_CONFIG, POSITION_CONFIG, CASCADE_OFFSET, modalSizeStorage, modalUtils } from "rails_modal_manager/modal_store"
@@ -170,7 +170,7 @@
170
170
  <% end %>
171
171
 
172
172
  <div class="rmm-content" data-rmm-modal-target="content">
173
- <%= yield if block_given? %>
173
+ <%= block_content if defined?(block_content) && block_content %>
174
174
  </div>
175
175
  </div>
176
176
  </div>
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RailsModalManager
4
- VERSION = "1.0.2"
4
+ VERSION = "1.0.4"
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.2
4
+ version: 1.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - reshacs