Skip to content

Commit

Permalink
fix: Auto close dialogs on route change
Browse files Browse the repository at this point in the history
  • Loading branch information
surajshetty3416 committed Jan 27, 2025
1 parent da2c5d0 commit 0393bc2
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 6 deletions.
2 changes: 1 addition & 1 deletion frontend/src/components/AlertDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
</template>

<script lang="ts" setup>
import { Dialog } from "frappe-ui";
import Dialog from "@/components/Controls/Dialog.vue";
import { onMounted, ref } from "vue";
const props = defineProps(["title", "message", "onClick"]);
Expand Down
29 changes: 29 additions & 0 deletions frontend/src/components/Controls/Dialog.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<template>
<Dialog v-bind="attrs" ref="dialogRef" @update:modelValue="emit('update:modelValue', $event)">
<template v-for="(_, name) in $slots" :key="name" v-slot:[name]="slotData">
<slot :name="name" v-bind="slotData"></slot>
</template>
</Dialog>
</template>

<script setup lang="ts">
import { Dialog } from "frappe-ui";
import { ref, useAttrs, watch } from "vue";
import { useRoute } from "vue-router";
const attrs = useAttrs();
const emit = defineEmits(["update:modelValue", "close"]);
const route = useRoute();
const dialogRef = ref();
// close dialog on route change
watch(
() => route.fullPath,
() => {
if (attrs.modelValue) {
emit("update:modelValue", false);
}
},
);
</script>
2 changes: 1 addition & 1 deletion frontend/src/components/Modals/NewComponent.vue
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@
</Dialog>
</template>
<script setup lang="ts">
import Dialog from "@/components/Controls/Dialog.vue";
import webComponent from "@/data/webComponent";
import useStore from "@/store";
import { posthog } from "@/telemetry";
import { BuilderComponent } from "@/types/Builder/BuilderComponent";
import Block from "@/utils/block";
import { getBlockCopy, getBlockString } from "@/utils/helpers";
import useComponentStore from "@/utils/useComponentStore";
import { Dialog } from "frappe-ui";
import { ref } from "vue";
const store = useStore();
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/Modals/NewFolder.vue
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@
</Dialog>
</template>
<script setup lang="ts">
import Dialog from "@/components/Controls/Dialog.vue";
import builderProjectFolder from "@/data/builderProjectFolder";
import { useVModel } from "@vueuse/core";
import { Dialog } from "frappe-ui";
import { ref } from "vue";
const folderName = ref("");
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/Modals/SelectFolder.vue
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@
</Dialog>
</template>
<script setup lang="ts">
import Dialog from "@/components/Controls/Dialog.vue";
import FolderIcon from "@/components/Icons/Folder.vue";
import builderProjectFolder from "@/data/builderProjectFolder";
import { useVModel } from "@vueuse/core";
import { Dialog } from "frappe-ui";
const props = defineProps<{
currentFolder: string;
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/PageScript.vue
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@
</div>
</template>
<script lang="ts" setup>
import Dialog from "@/components/Controls/Dialog.vue";
import { webPages } from "@/data/webPage";
import useStore from "@/store";
import { posthog } from "@/telemetry";
import { BuilderPage } from "@/types/Builder/BuilderPage";
import { Dialog } from "frappe-ui";
import { defineComponent, ref } from "vue";
import { toast } from "vue-sonner";
import CodeEditor from "./Controls/CodeEditor.vue";
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/pages/PageBuilder.vue
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ import BuilderCanvas from "@/components/BuilderCanvas.vue";
import BuilderLeftPanel from "@/components/BuilderLeftPanel.vue";
import BuilderRightPanel from "@/components/BuilderRightPanel.vue";
import BuilderToolbar from "@/components/BuilderToolbar.vue";
import Dialog from "@/components/Controls/Dialog.vue";
import { webPages } from "@/data/webPage";
import { sessionUser } from "@/router";
import useStore from "@/store";
Expand All @@ -114,7 +115,6 @@ import {
useDebounceFn,
useMagicKeys,
} from "@vueuse/core";
import { Dialog } from "frappe-ui";
import { computed, onActivated, onDeactivated, provide, ref, toRef, watch, watchEffect } from "vue";
import { useRoute, useRouter } from "vue-router";
import CodeEditor from "../components/Controls/CodeEditor.vue";
Expand Down

0 comments on commit 0393bc2

Please sign in to comment.