Skip to content

Commit

Permalink
Confirm potential to lose changes before navigating
Browse files Browse the repository at this point in the history
  • Loading branch information
allanlasser committed Dec 12, 2024
1 parent e1b96f0 commit a89bf61
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/lib/components/viewer/RedactionLayer.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ So this layer is only showing unsaved redactions.
<script lang="ts">
import { onMount } from "svelte";
import { _ } from "svelte-i18n";
import { beforeNavigate } from "$app/navigation";
export let active = false;
export let page_number: number; // 0-indexed
Expand Down Expand Up @@ -106,6 +107,14 @@ So this layer is only showing unsaved redactions.
currentRedaction = null;
}
beforeNavigate(({ cancel }) => {
if ($redactions.length > 0) {
if (!confirm($_("redact.cancelWarning"))) {
cancel();
}
}
});
onMount(() => {
// before unmounting the component, clear the current redactions
return () => {
Expand Down

0 comments on commit a89bf61

Please sign in to comment.