Skip to content

Commit

Permalink
Keep alive export dialog state
Browse files Browse the repository at this point in the history
  • Loading branch information
cdauth committed Mar 9, 2024
1 parent f920856 commit b97e366
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 7 deletions.
10 changes: 6 additions & 4 deletions frontend/src/lib/components/toolbox/toolbox-tools-dropdown.vue
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,12 @@
@hidden="dialog = undefined"
></ShareDialog>

<ExportDialog
v-if="dialog === 'export'"
@hidden="dialog = undefined"
></ExportDialog>
<KeepAlive>
<ExportDialog
v-if="dialog === 'export'"
@hidden="dialog = undefined"
></ExportDialog>
</KeepAlive>

<EditFilterDialog
v-if="dialog === 'edit-filter' && client.padData"
Expand Down
16 changes: 13 additions & 3 deletions frontend/src/lib/utils/modal.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Modal from "bootstrap/js/dist/modal";
import { type Ref, shallowRef, watch, watchEffect, reactive, readonly, effectScope } from "vue";
import { type Ref, shallowRef, watchEffect, reactive, readonly, effectScope, onActivated, ref, onDeactivated } from "vue";
import { useMaxBreakpoint } from "./bootstrap";
import { fixOnCleanup } from "./vue";

Expand Down Expand Up @@ -58,10 +58,20 @@ export function useModal(modalRef: Ref<HTMLElement | undefined>, { onShown, onHi
}
});

watch(modalRef, (newRef, oldRef, onCleanup_) => {
const isActivated = ref(true);
onActivated(() => {
isActivated.value = true;
});
onDeactivated(() => {
isActivated.value = false;
});

watchEffect((onCleanup_) => {
const onCleanup = fixOnCleanup(onCleanup_);

if (newRef) {
if (modalRef.value && isActivated.value) {
const newRef = modalRef.value;

if (!lastFocusedEl) {
lastFocusedEl = document.activeElement ?? undefined;
}
Expand Down

0 comments on commit b97e366

Please sign in to comment.