fix: reset the edit dialog when switching books
This commit is contained in:
@@ -9,8 +9,17 @@
|
||||
let { book, open = $bindable() }: { book?: Book; open: boolean } = $props();
|
||||
</script>
|
||||
|
||||
<!--
|
||||
This dialog is mounted once, in (root)/(library)/+layout.svelte, and `book`
|
||||
changes underneath it as different books are edited. bookToEdit is never
|
||||
cleared, so {#if book} stays true and the tab forms never unmount — they seed
|
||||
local state from `book` on mount, so without this key you would open Edit on a
|
||||
second book and see the first book's authors, tags and cover, then save them
|
||||
onto the wrong record. Keying on the id remounts the forms per book.
|
||||
-->
|
||||
<Dialog.Root bind:open>
|
||||
{#if book}
|
||||
{#key book.id}
|
||||
<Dialog.Content class="sm:max-w-xl">
|
||||
<Tabs.Root value="metadata" class="h-[500px] max-w-xl py-4 md:h-[700px]">
|
||||
<Tabs.List class="grid w-full grid-cols-3">
|
||||
@@ -35,5 +44,6 @@
|
||||
</Tabs.Content>
|
||||
</Tabs.Root>
|
||||
</Dialog.Content>
|
||||
{/key}
|
||||
{/if}
|
||||
</Dialog.Root>
|
||||
|
||||
Reference in New Issue
Block a user