Skip to content

feat(localize): leave the editor once the accepted boxes land - #385

Merged
Chouffe merged 3 commits into
mainfrom
worktree-localize-editor-close-on-accept
Aug 13, 2026
Merged

feat(localize): leave the editor once the accepted boxes land#385
Chouffe merged 3 commits into
mainfrom
worktree-localize-editor-close-on-accept

Conversation

@Chouffe

@Chouffe Chouffe commented Aug 13, 2026

Copy link
Copy Markdown
Collaborator

What

Confirming the localize editor's Accept boxes popover — with Enter or its own button — now closes the editor and returns to the object's cockpit page (/localize/:seq/object/:lane).

Why

Accepting the remainder settles every frame of the object, so the editor has nothing left to show. It stayed open anyway, and the annotator had to press Escape to get back to a cockpit that had already moved on without them.

How

LocalizeObjectEditor's onAcceptRemaining takes an optional onAccepted callback; both confirm paths pass the editor's own close, so the exit runs the existing shrink-back-into-the-grid animation rather than a hard unmount. LocalizeAlertPage fires that callback from the quick-accept mutation's onSuccess.

Closing on the write rather than on the gesture is deliberate: a failed accept leaves the object unfinished, so the editor stays open with its "Failed to accept boxes" toast still about the object in front of you.

The rail's copy of the same popover passes no callback and is unchanged — there is no editor to close there.

Two holes the first commit opened, and their fixes

Handing a close to the page makes it callable long after the gesture that armed it. Two consequences, each its own commit:

  • Late callback after the editor is gone. Accept, then leave by another door — browser Back, which keeps the cockpit page (and its mutation) mounted — and the close ran on an unmounted editor, navigating the annotator back to where they had just left. mountedRef already guards the exit animation's finish handler for this reason; the guard now sits on the whole request.
  • Close frozen at gesture time. requestClose closes over the open frame, and nothing stops an ArrowRight while the bulk upsert is in flight. The editor would shrink into the cell of a frame already left, possibly one scrolled out of view. A ref resolves the callback to the current close instead — the same trick clearRef uses to keep the keyboard handler from re-binding.

Testing

Editor level: Enter-confirm and click-confirm each close once the callback fires; a callback arriving after unmount does nothing; the close targets the frame the annotator is on rather than the one they accepted from.

Page level (LocalizeAlertPage.test.tsx, "accept popover → from the editor"): the editor closes to /localize/101/object/102 once the write lands, and stays on screen with its failure toast when the bulk write rejects.

That page pair exists because an earlier editor-level "stays put" test was vacuous — the failure semantics live in the page's { onSuccess }. Swapping it for { onSettled }, which would close on a failed accept and bury the error toast, left the entire suite green. Both page tests were watched failing against that mutant before being kept; the redundant editor test is gone.

Full frontend suite 1503/1503, type-check, lint and format:check clean.

Caveat: jsdom has no Web Animations API, so most editor tests exercise the non-animated fallback; the frame-targeting test drives the suite's existing WAAPI stub. The real animated close was verified by hand in the browser.

Confirming the editor's "Accept boxes" popover settles every remaining
frame of the object, so there is nothing left to do on that screen —
but the editor stayed open, and the annotator had to press Escape to
get back to a cockpit that had already moved on without them.

The confirm paths (Enter and the popover's own button) now hand the
page a callback, and the page fires it from the mutation's onSuccess.
Closing on the write rather than on the gesture is what keeps a failed
accept where it belongs: the editor stays open with its error toast
still about the object in front of you. The close runs through the
editor's own requestClose, so it shrinks back into the grid cell
exactly as Escape does.

The rail's copy of the same popover passes no callback — there is no
editor to close there — and is untouched.
Handing `requestClose` to the page made it reachable long after the
gesture that armed it: the write can land once the annotator has
already left by another door — browser Back, which keeps the cockpit
page and its mutation mounted. The close then ran on an unmounted
editor and navigated them back to it.

`mountedRef` already guards the exit animation's own finish handler
for the same reason; this takes it one step earlier, to the whole
request.
…they accepted from

Two things review turned up in the accept-close wiring.

The close handed to the page was frozen at gesture time: `requestClose`
closes over the open frame, and nothing stops an ArrowRight while the
bulk upsert is in flight. The write would land and the editor shrink
into the cell of a frame already left — possibly one scrolled out of
view, so it flew off toward nothing. A ref resolves the callback to the
current close instead, the same trick `clearRef` uses to keep the
keyboard handler from re-binding.

And "stays put when the write never lands" tested nothing: the failure
semantics live in the page's `{ onSuccess }`, so an editor-level test
could only re-assert what the test above it already pins. Swapping that
for `onSettled` — which would close on a FAILED accept and bury the
error toast — left the whole suite green. The guard now sits where the
behavior does, in a page test that rejects the bulk write and asserts
the editor is still on screen; its sibling covers the success close.
Both were watched failing against that mutant first.
@Chouffe
Chouffe merged commit 3780ca3 into main Aug 13, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant