Fix navigation from stacked dialogs with the same name (#23698)

* Fix navigation from stacked dialogs

* lint fix

* Keep only 1 instance per dialog tag in the stack
This commit is contained in:
Petar Petrov 2025-01-14 10:25:01 +02:00 committed by GitHub
parent eda0ea077c
commit 6f9a385619
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -104,6 +104,12 @@ export const showDialog = async (
addHistory
);
}
const dialogIndex = OPEN_DIALOG_STACK.findIndex(
(state) => state.dialogTag === dialogTag
);
if (dialogIndex !== -1) {
OPEN_DIALOG_STACK.splice(dialogIndex, 1);
}
OPEN_DIALOG_STACK.push({
element,
root,
@ -173,8 +179,10 @@ export const closeLastDialog = async () => {
export const closeAllDialogs = async () => {
for (let i = OPEN_DIALOG_STACK.length - 1; i >= 0; i--) {
// eslint-disable-next-line no-await-in-loop
const closed = await closeDialog(OPEN_DIALOG_STACK[i].dialogTag);
const closed =
!OPEN_DIALOG_STACK[i] ||
// eslint-disable-next-line no-await-in-loop
(await closeDialog(OPEN_DIALOG_STACK[i].dialogTag));
if (!closed) {
return false;
}