fix(editor): Task 8 round 1, sync tag, cascaded leave ask

This commit is contained in:
bchanot committed 2026-11-14 15:01:23 +01:00
1 parent 07bebbc855
commit 579d8afff4
10 files changed
+359 -83

No files matched your search

@@ -239,8 +239,8 @@ function Workspace(props: Props & { tag: string }) {
}
/**
* The editor of the signed-in account's session tag (criterion 22). Until the tag is
* known nothing is restored or written (fail closed); another tag is another editor.
* The editor of the signed-in account's session tag (criterion 22), resolved at once;
* nobody signed in, no editor. Another tag is another editor.
*/
export default function EditorWorkspace(props: Props) {
const tag = useSessionTag()
@@ -13,8 +13,9 @@ export type DiscardTarget = 'form' | 'dialog'
* forced close (the element vanished) goes ahead and says the draft was dropped
* (BDR-115); a form with nothing typed says nothing.
* `askToLeave` is the form's own « Annuler ». The browser's unload is guarded too.
* A history jump out of the editor that was held for this question (criterion 23) is
* what `discard` carries out; « Continuer la saisie » drops it.
* A history jump out of the editor held for this question (criterion 23) is what
* `discard` carries on (the next dirty layer asks, or the jump goes); « Continuer la
* saisie » drops it.
*/
export function useDirtyGuard(
guards: Guards,
@@ -43,8 +44,12 @@ export function useDirtyGuard(
guards.holdLeave(null)
setConfirming(null)
},
/** « Abandonner »: the held leave when there is one, else `close`. */
discard: (close: () => void) => () => (guards.takeLeave() ?? close)(),
/** « Abandonner »: the leave held for this layer when there is one, else `close`. */
discard: (close: () => void) => () => {
const leave = guards.takeLeave(layer)
if (leave) leave({ close, keep: () => setConfirming(null) })
else close()
},
}
}