Skip to content

Commit 887dcac

Browse files
authored
Fix edit motion FOUC in P&M page (#86)
1 parent 58140f2 commit 887dcac

1 file changed

Lines changed: 6 additions & 12 deletions

File tree

src/routes/dashboard/points-motions/+page.svelte

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
import EditMotionContent from "$lib/components/modals/EditMotionContent.svelte";
1717
import UniModal from "$lib/components/modals/UniModal.svelte";
1818
import MotionForm, { numSpeakersStr } from "$lib/components/motions/form/MotionForm.svelte";
19-
import { createSpeaker } from "$lib/components/SpeakerList.svelte";
2019
import { getSessionContext } from "$lib/context/index.svelte";
2120
import { findDelegate } from "$lib/db/delegates";
2221
import { db } from "$lib/db/index.svelte";
@@ -39,9 +38,7 @@
3938
const { motions, selectedMotion, selectedMotionState, delegates, sortOrder } = getSessionContext();
4039
const pid = $props.id();
4140
42-
let openModals = $state({
43-
editMotion: -1
44-
});
41+
let editMotionModal = $state({ open: false, index: -1 });
4542
// A clone of $motions used solely for use:dndzone
4643
let dndItems = $derived(proxify($motions));
4744
@@ -210,7 +207,7 @@
210207
"data-dnd-dragging:preset-tonal-primary"
211208
]}
212209
animate:flip={{ duration: 150 }}
213-
ondblclick={() => openModals.editMotion = i}
210+
ondblclick={() => editMotionModal = { open: true, index: i }}
214211
{...a11yLabel(`${delName}'s Motion`)}
215212
>
216213
<td>{motionName(motion)}</td>
@@ -239,7 +236,7 @@
239236
</button>
240237
<button
241238
class="btn-icon-std p-1"
242-
onclick={() => openModals.editMotion = i}
239+
onclick={() => editMotionModal = { open: true, index: i }}
243240
{...a11yLabel(`Edit ${delName}'s Motion`)}
244241
>
245242
<MdiPencil />
@@ -255,13 +252,10 @@
255252
</div>
256253
</div>
257254
<UniModal
258-
bind:open={
259-
() => openModals.editMotion >= 0,
260-
open => { if (!open) openModals.editMotion = -1}
261-
}
262-
onSubmit={(m: Motion) => editMotion(openModals.editMotion, m)}
255+
bind:open={editMotionModal.open}
256+
onSubmit={(m: Motion) => editMotion(editMotionModal.index, m)}
263257
>
264258
{#snippet content(exitState)}
265-
<EditMotionContent motion={$motions[openModals.editMotion]} {motionSchema} {exitState} />
259+
<EditMotionContent motion={$motions[editMotionModal.index]} {motionSchema} {exitState} />
266260
{/snippet}
267261
</UniModal>

0 commit comments

Comments
 (0)