Skip to content

Flush the description's pending autosave on every close path - #351

Merged
dmnyc merged 1 commit into
mainfrom
fix/alt-flush-close
Sep 22, 2026
Merged

dmnyc merged 1 commit into
mainfrom
fix/alt-flush-close

Conversation

@dmnyc

@dmnyc dmnyc commented Sep 22, 2026

Copy link
Copy Markdown
Owner

Fixes #342. Stacked on #341 — review and merge that first; this PR's base is feat/imeta-alt-text, so the diff shown here is just this fix.

The gap

The ALT row committed on its three own exits (Save description, Escape, trash) — but pages closed it for their own reasons, and each dropped the last half-second of the debounced autosave:

  • chip toggle (re-tap the chip to close the row)
  • the review window starting, both composers — worst case: Post pressed mid-word and the note publishes without the tail of the description
  • the tab's account switch (the old account's draft was persisted without it)

The fix

  • buildAltEditorRow exposes flushPending() on the row: fires the pending onChange if the 500ms debounce is live.
  • closeAltEditor(flush) flushes by default.
  • Two closes deliberately don't: image removal passes false (the slot is gone — flushing would write one image's words onto another), and the drag closes before the splice so the flush still lands in the slot the row was opened for.
  • The panel's Post press closes-with-flush at the top of the handler; the tab's account switch closes before flushDraft(), the old account's last chance to take the tail.

Tests pin all of it: the exposed flush, the flush !== false guard, removal's false, drag-before-splice ordering, and the two load-bearing call sites.

…'s own exits

The row committed on its three own exits — Save description, Escape,
the trash — but pages closed it for their own reasons, and each of
those dropped the last half-second of typing on the floor: the chip
toggle, the review window starting (worst case: Post pressed mid-word
and the note publishes without the tail), an account moving under the
tab (the old account's draft persisted without it).

The row exposes its pending autosave now, and closeAltEditor flushes it
by default. Two closes deliberately do not: removing the image (the
slot is gone; flushing would write one image's words onto another) and
the drag, which closes BEFORE the splice so the flush still lands in
the right slot. The tab's account switch closes before the old draft
is persisted, which is that account's last chance to take the tail.

Fixes #342.
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.

ALT editor: flush the pending autosave on every close path, not just Save/Escape/trash

1 participant