rails_modal_manager 1.0.4 → 1.0.5
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: 07e612cdd8425a4042524c46b43900aae571126866f8b6816a6f4b3174941cdc
|
|
4
|
+
data.tar.gz: ac92ca48a207e80b7a00bbcf2346820ec6bfaa9dd94ad2c07840331fdc109ed4
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d1a29aa6ff0dc96b8acd0f503b325eeba85f6961b3cb28be80f62a0f3af2061be43b7c9488a1b1e3d4e5e6bfb9b0929afb96794070af2db202145c882f409762
|
|
7
|
+
data.tar.gz: feaa856f515612f6080bd5f51c3b1b8ed18b877992df59013143b280644e5af3622fba89537d4ad1b2bddd6aa14ebd4ebb0f92bf1a461f060dbc31f8697f6951
|
|
@@ -186,11 +186,10 @@ export default class extends Controller {
|
|
|
186
186
|
|
|
187
187
|
// Remove from history stack (unless closed by history)
|
|
188
188
|
if (this.enableHistoryStackValue && source !== 'history') {
|
|
189
|
-
//
|
|
190
|
-
[...descendants].reverse()
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
historyStackManager.removeHisData('modal', modalId)
|
|
189
|
+
// Collect all modal IDs to remove (descendants + current modal)
|
|
190
|
+
const allIdsToRemove = [...[...descendants].reverse(), modalId]
|
|
191
|
+
// Remove all at once with single history.go() call
|
|
192
|
+
historyStackManager.removeMultipleHisData('modal', allIdsToRemove)
|
|
194
193
|
}
|
|
195
194
|
|
|
196
195
|
// Close all descendants first (in reverse order - newest first)
|
|
@@ -673,16 +672,14 @@ export default class extends Controller {
|
|
|
673
672
|
// Minimize entire group if has parent
|
|
674
673
|
modalStore.minimizeModalGroup(modalId)
|
|
675
674
|
|
|
676
|
-
// Remove from history stack (use
|
|
675
|
+
// Remove from history stack (use removeMultipleHisData to sync browser history)
|
|
677
676
|
if (this.enableHistoryStackValue) {
|
|
678
677
|
const rootId = modalStore.getRootModal(modalId)
|
|
679
678
|
const descendants = modalStore.getAllDescendants(rootId)
|
|
680
|
-
const allModalIds = [rootId, ...descendants]
|
|
679
|
+
const allModalIds = [rootId, ...descendants].reverse()
|
|
681
680
|
|
|
682
|
-
// Remove
|
|
683
|
-
|
|
684
|
-
historyStackManager.removeHisData('modal', id)
|
|
685
|
-
})
|
|
681
|
+
// Remove all at once with single history.go() call
|
|
682
|
+
historyStackManager.removeMultipleHisData('modal', allModalIds)
|
|
686
683
|
}
|
|
687
684
|
|
|
688
685
|
this.dispatch('minimize', { detail: { modalId: modalId } })
|
|
@@ -199,6 +199,55 @@ function silentRemoveHisData(type, id) {
|
|
|
199
199
|
return true;
|
|
200
200
|
}
|
|
201
201
|
|
|
202
|
+
/**
|
|
203
|
+
* Remove multiple items from history stack at once
|
|
204
|
+
* - Remove all specified items from stack
|
|
205
|
+
* - Remove functions from closeFunctions (memory cleanup)
|
|
206
|
+
* - Synchronize browser history with single history.go(-count) call
|
|
207
|
+
*
|
|
208
|
+
* @param {string} type - Target type
|
|
209
|
+
* @param {string[]} ids - Array of target IDs to remove
|
|
210
|
+
* @returns {number} Number of items successfully removed
|
|
211
|
+
*/
|
|
212
|
+
function removeMultipleHisData(type, ids) {
|
|
213
|
+
if (typeof window === 'undefined') return 0;
|
|
214
|
+
if (!isEnabledForDevice(type)) return 0;
|
|
215
|
+
if (!ids || ids.length === 0) return 0;
|
|
216
|
+
|
|
217
|
+
const hisData = loadHisData();
|
|
218
|
+
let removedCount = 0;
|
|
219
|
+
|
|
220
|
+
// Remove each item silently (without history.back)
|
|
221
|
+
ids.forEach(id => {
|
|
222
|
+
const index = hisData.findIndex(
|
|
223
|
+
(item) => item.type === type && item.id === id
|
|
224
|
+
);
|
|
225
|
+
|
|
226
|
+
if (index !== -1) {
|
|
227
|
+
const item = hisData[index];
|
|
228
|
+
|
|
229
|
+
// Remove function from closeFunctions (memory cleanup)
|
|
230
|
+
if (item.closeKey) {
|
|
231
|
+
closeFunctions.delete(item.closeKey);
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
// Remove item from stack
|
|
235
|
+
hisData.splice(index, 1);
|
|
236
|
+
removedCount++;
|
|
237
|
+
}
|
|
238
|
+
});
|
|
239
|
+
|
|
240
|
+
if (removedCount > 0) {
|
|
241
|
+
saveHisData(hisData);
|
|
242
|
+
|
|
243
|
+
// Synchronize browser history with single call
|
|
244
|
+
isDirectClose = true;
|
|
245
|
+
window.history.go(-removedCount);
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
return removedCount;
|
|
249
|
+
}
|
|
250
|
+
|
|
202
251
|
/**
|
|
203
252
|
* Remove last item from history stack and execute close function (used for back button)
|
|
204
253
|
* @returns {Object|null} Closed item info or null
|
|
@@ -310,6 +359,7 @@ const historyStackManager = {
|
|
|
310
359
|
// Core functions
|
|
311
360
|
addHisData,
|
|
312
361
|
removeHisData,
|
|
362
|
+
removeMultipleHisData,
|
|
313
363
|
silentRemoveHisData,
|
|
314
364
|
popHisData,
|
|
315
365
|
|