mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-12 20:06:33 +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) {
|
||||
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({
|
||||
element,
|
||||
root,
|
||||
@ -105,16 +113,22 @@ export const showDialog = async (
|
||||
addHistory,
|
||||
});
|
||||
const newState = { dialog: dialogTag };
|
||||
if (state?.dialog) {
|
||||
// if the dialog is already open, replace the name
|
||||
mainWindow.history.replaceState(newState, "");
|
||||
if (history.state?.dialog) {
|
||||
// if a dialog is already open, replace the name
|
||||
history.replaceState(newState, "");
|
||||
} else {
|
||||
// if the dialog is not open, push a new state so back() will close the dialog
|
||||
mainWindow.history.replaceState({ ...state, opensDialog: true }, "");
|
||||
mainWindow.history.pushState(newState, "");
|
||||
// if a dialog is not open, push a new state so back() will close the dialog
|
||||
history.replaceState({ ...history.state, opensDialog: true }, "");
|
||||
history.pushState(newState, "");
|
||||
}
|
||||
}
|
||||
|
||||
// Get the focus targets after the dialog closes
|
||||
LOADED[dialogTag].closedFocusTargets = ancestorsWithProperty(
|
||||
deepActiveElement(),
|
||||
FOCUS_TARGET
|
||||
);
|
||||
|
||||
const dialogElement = await LOADED[dialogTag].element;
|
||||
|
||||
// Append it again so it's the last element in the root,
|
||||
|
Loading…
x
Reference in New Issue
Block a user