rails_modal_manager 1.0.44 → 1.0.45

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: b0752ed8f79cdbe227d9a4010cab4ac2f73cf59e75dade5572bc98cda6374e2d
4
- data.tar.gz: 5d9d4f28f9f9a4535d5646e707540e21e641f49e5b757a4d50d9cc7afbf1ef54
3
+ metadata.gz: 35bbae9104923aaa6bc1fa87eacd8616c2ef0aaf538ed1210fb369c3f25e89e2
4
+ data.tar.gz: 34ba022c5adac89ff47c3f505215acef624056da6f48afaec02bc42e611e587e
5
5
  SHA512:
6
- metadata.gz: fc8042fd0499d9f7076c8ad822ef9849a324f12a733d23a5449b1b07677f9bb73b8b9e9d88324baec9b448ffcdf983d83a1a9d3f6f2e346b87da23fdfd39e9fb
7
- data.tar.gz: eb4dc333dd595d3bac849153b8e5f7cde6ecefecf3e5d9fa056309e3a479e8e96d70e9734aabd219170a920e79f3e009099128d3a0b5220fb5c5d394d5925545
6
+ metadata.gz: f94273a89dcd52dba439b464196f7c3db208a28405c01f582227e81bb3c709f236074d6a5bca7c6dcdbf53dcf822357d47da9ae643aa23463f25a5d000b55d35
7
+ data.tar.gz: 2c8f6ffd4bfced2dcf0ae66a5f8b0f39b63d58fa490f5bbdc7e114f3cbd88810d6c73c054a435e5a3a041d5e3adc7ff67f4e323305f45ed3bb367b2e9748a278
@@ -297,6 +297,15 @@ export default class extends Controller {
297
297
  const modal = this.element.closest('.rmm-modal')
298
298
  if (!modal) return
299
299
 
300
+ // Abort all pending AJAX requests from all submenu controllers
301
+ modal.querySelectorAll('[data-controller*="rmm-submenu"]').forEach(el => {
302
+ const ctrl = this.application.getControllerForElementAndIdentifier(el, 'rmm-submenu')
303
+ if (ctrl && ctrl.currentAbortController) {
304
+ ctrl.currentAbortController.abort()
305
+ ctrl.currentAbortController = null
306
+ }
307
+ })
308
+
300
309
  // Hide all submenu groups
301
310
  modal.querySelectorAll('.rmm-submenu-group').forEach(group => {
302
311
  group.classList.remove('rmm-submenu-group-active')
@@ -45,7 +45,6 @@ export default class extends Controller {
45
45
  this.ajaxCache = new Map()
46
46
  this.currentItemId = null
47
47
  this.currentAbortController = null
48
- this.currentRequestId = 0
49
48
 
50
49
  // Find initial active item
51
50
  const activeItem = this.element.querySelector('.rmm-submenu-item.rmm-active')
@@ -165,14 +164,18 @@ export default class extends Controller {
165
164
  return
166
165
  }
167
166
 
168
- // Abort previous pending request
167
+ // Abort previous pending request from this controller
169
168
  if (this.currentAbortController) {
170
169
  this.currentAbortController.abort()
171
170
  }
172
171
 
173
172
  const abortController = new AbortController()
174
173
  this.currentAbortController = abortController
175
- const requestId = ++this.currentRequestId
174
+
175
+ // Global request counter on the shared content container
176
+ // This ensures cross-controller coordination (e.g., when switching sidebar groups)
177
+ const requestId = (parseInt(contentContainer.dataset.rmmRequestId || '0', 10) + 1)
178
+ contentContainer.dataset.rmmRequestId = requestId
176
179
 
177
180
  // Show loading state
178
181
  contentContainer.classList.add('rmm-tab-loading')
@@ -194,7 +197,8 @@ export default class extends Controller {
194
197
  const html = await response.text()
195
198
 
196
199
  // Validate: only update if this is still the latest request
197
- if (this.currentRequestId !== requestId) {
200
+ // Uses the shared counter on the DOM element, not instance-level counter
201
+ if (parseInt(contentContainer.dataset.rmmRequestId, 10) !== requestId) {
198
202
  return
199
203
  }
200
204
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RailsModalManager
4
- VERSION = "1.0.44"
4
+ VERSION = "1.0.45"
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.44
4
+ version: 1.0.45
5
5
  platform: ruby
6
6
  authors:
7
7
  - reshacs