mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-13 20:36:35 +00:00
Fix integrations dialog (#23328)
* Fix integrations dialog * tweak comments
This commit is contained in:
parent
8a46ef6168
commit
2d902a0688
@ -87,15 +87,23 @@ export const showDialog = async (
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the focus targets after the dialog closes
|
|
||||||
LOADED[dialogTag].closedFocusTargets = ancestorsWithProperty(
|
|
||||||
deepActiveElement(),
|
|
||||||
FOCUS_TARGET
|
|
||||||
);
|
|
||||||
|
|
||||||
const { state } = mainWindow.history;
|
|
||||||
// if the same dialog is already open, don't push state
|
|
||||||
if (addHistory) {
|
if (addHistory) {
|
||||||
|
const { history } = mainWindow;
|
||||||
|
if (history.state?.dialog && !OPEN_DIALOG_STACK.length) {
|
||||||
|
// theres is a dialog state in history, but no dialogs open
|
||||||
|
// wait for history.back() to update the state
|
||||||
|
await new Promise((resolve) => {
|
||||||
|
setTimeout(resolve);
|
||||||
|
});
|
||||||
|
return showDialog(
|
||||||
|
element,
|
||||||
|
root,
|
||||||
|
dialogTag,
|
||||||
|
dialogParams,
|
||||||
|
dialogImport,
|
||||||
|
addHistory
|
||||||
|
);
|
||||||
|
}
|
||||||
OPEN_DIALOG_STACK.push({
|
OPEN_DIALOG_STACK.push({
|
||||||
element,
|
element,
|
||||||
root,
|
root,
|
||||||
@ -105,16 +113,22 @@ export const showDialog = async (
|
|||||||
addHistory,
|
addHistory,
|
||||||
});
|
});
|
||||||
const newState = { dialog: dialogTag };
|
const newState = { dialog: dialogTag };
|
||||||
if (state?.dialog) {
|
if (history.state?.dialog) {
|
||||||
// if the dialog is already open, replace the name
|
// if a dialog is already open, replace the name
|
||||||
mainWindow.history.replaceState(newState, "");
|
history.replaceState(newState, "");
|
||||||
} else {
|
} else {
|
||||||
// if the dialog is not open, push a new state so back() will close the dialog
|
// if a dialog is not open, push a new state so back() will close the dialog
|
||||||
mainWindow.history.replaceState({ ...state, opensDialog: true }, "");
|
history.replaceState({ ...history.state, opensDialog: true }, "");
|
||||||
mainWindow.history.pushState(newState, "");
|
history.pushState(newState, "");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Get the focus targets after the dialog closes
|
||||||
|
LOADED[dialogTag].closedFocusTargets = ancestorsWithProperty(
|
||||||
|
deepActiveElement(),
|
||||||
|
FOCUS_TARGET
|
||||||
|
);
|
||||||
|
|
||||||
const dialogElement = await LOADED[dialogTag].element;
|
const dialogElement = await LOADED[dialogTag].element;
|
||||||
|
|
||||||
// Append it again so it's the last element in the root,
|
// Append it again so it's the last element in the root,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user