rails_modal_manager 1.0.42 → 1.0.44
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: b0752ed8f79cdbe227d9a4010cab4ac2f73cf59e75dade5572bc98cda6374e2d
|
|
4
|
+
data.tar.gz: 5d9d4f28f9f9a4535d5646e707540e21e641f49e5b757a4d50d9cc7afbf1ef54
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: fc8042fd0499d9f7076c8ad822ef9849a324f12a733d23a5449b1b07677f9bb73b8b9e9d88324baec9b448ffcdf983d83a1a9d3f6f2e346b87da23fdfd39e9fb
|
|
7
|
+
data.tar.gz: eb4dc333dd595d3bac849153b8e5f7cde6ecefecf3e5d9fa056309e3a479e8e96d70e9734aabd219170a920e79f3e009099128d3a0b5220fb5c5d394d5925545
|
|
@@ -44,6 +44,8 @@ export default class extends Controller {
|
|
|
44
44
|
connect() {
|
|
45
45
|
this.ajaxCache = new Map()
|
|
46
46
|
this.currentItemId = null
|
|
47
|
+
this.currentAbortController = null
|
|
48
|
+
this.currentRequestId = 0
|
|
47
49
|
|
|
48
50
|
// Find initial active item
|
|
49
51
|
const activeItem = this.element.querySelector('.rmm-submenu-item.rmm-active')
|
|
@@ -140,6 +142,8 @@ export default class extends Controller {
|
|
|
140
142
|
|
|
141
143
|
/**
|
|
142
144
|
* AJAX mode: Load content from URL
|
|
145
|
+
* Uses AbortController to cancel previous pending requests and
|
|
146
|
+
* validates response against current active item to prevent race conditions.
|
|
143
147
|
*/
|
|
144
148
|
async loadAjaxContent(item) {
|
|
145
149
|
const url = item.dataset.url
|
|
@@ -161,12 +165,22 @@ export default class extends Controller {
|
|
|
161
165
|
return
|
|
162
166
|
}
|
|
163
167
|
|
|
168
|
+
// Abort previous pending request
|
|
169
|
+
if (this.currentAbortController) {
|
|
170
|
+
this.currentAbortController.abort()
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
const abortController = new AbortController()
|
|
174
|
+
this.currentAbortController = abortController
|
|
175
|
+
const requestId = ++this.currentRequestId
|
|
176
|
+
|
|
164
177
|
// Show loading state
|
|
165
178
|
contentContainer.classList.add('rmm-tab-loading')
|
|
166
179
|
contentContainer.innerHTML = '<div class="rmm-tab-loader"><div class="rmm-spinner"></div><span>로딩 중...</span></div>'
|
|
167
180
|
|
|
168
181
|
try {
|
|
169
182
|
const response = await fetch(url, {
|
|
183
|
+
signal: abortController.signal,
|
|
170
184
|
headers: {
|
|
171
185
|
'Accept': 'text/html',
|
|
172
186
|
'X-Requested-With': 'XMLHttpRequest'
|
|
@@ -179,6 +193,11 @@ export default class extends Controller {
|
|
|
179
193
|
|
|
180
194
|
const html = await response.text()
|
|
181
195
|
|
|
196
|
+
// Validate: only update if this is still the latest request
|
|
197
|
+
if (this.currentRequestId !== requestId) {
|
|
198
|
+
return
|
|
199
|
+
}
|
|
200
|
+
|
|
182
201
|
// Cache the response
|
|
183
202
|
if (this.cacheAjaxValue) {
|
|
184
203
|
this.ajaxCache.set(url, html)
|
|
@@ -192,6 +211,11 @@ export default class extends Controller {
|
|
|
192
211
|
detail: { modalId: this.modalIdValue, itemId: item.dataset.itemId, fromCache: false }
|
|
193
212
|
})
|
|
194
213
|
} catch (error) {
|
|
214
|
+
// Ignore abort errors (expected when switching tabs quickly)
|
|
215
|
+
if (error.name === 'AbortError') {
|
|
216
|
+
return
|
|
217
|
+
}
|
|
218
|
+
|
|
195
219
|
console.error('RMM Submenu: Failed to load content', error)
|
|
196
220
|
contentContainer.innerHTML = `
|
|
197
221
|
<div class="rmm-tab-error">
|