dialog: prevent closing underlying modal
Signed-off-by: Varun Patil <radialapps@gmail.com>pull/1010/head
parent
213a3d3778
commit
6c9fd552e4
|
@ -28,7 +28,17 @@ type ConfirmOptions = {
|
||||||
// Register fragment navigation
|
// Register fragment navigation
|
||||||
bus.on('memories:fragment:pop:dialog', () => {
|
bus.on('memories:fragment:pop:dialog', () => {
|
||||||
const selectors = ['button.oc-dialog-close', '[role="dialog"]:last-of-type button.modal-container__close'].join(', ');
|
const selectors = ['button.oc-dialog-close', '[role="dialog"]:last-of-type button.modal-container__close'].join(', ');
|
||||||
(document.querySelector(selectors) as HTMLElement)?.click?.();
|
const button = document.querySelector(selectors) as HTMLElement;
|
||||||
|
if (!button?.click) return;
|
||||||
|
|
||||||
|
// Some dialogs are simply modals, so we need to make sure that
|
||||||
|
// we don't close the underlying modal when closing the dialog.
|
||||||
|
// This happens if the dialog was actually closed by a button,
|
||||||
|
// and the route was subsequently popped by the fragment service.
|
||||||
|
if (button.closest('.memories-modal')) return;
|
||||||
|
|
||||||
|
// Close the dialog
|
||||||
|
button.click();
|
||||||
});
|
});
|
||||||
|
|
||||||
export function confirmDestructive(options: ConfirmOptions): Promise<boolean> {
|
export function confirmDestructive(options: ConfirmOptions): Promise<boolean> {
|
||||||
|
|
Loading…
Reference in New Issue