Skip to content

Return to the draft after opening its attached image - #2882

Merged
max-sixty merged 3 commits into
mainfrom
draft-survives-image-preview
Oct 14, 2026
Merged

max-sixty merged 3 commits into
mainfrom
draft-survives-image-preview

Conversation

@max-sixty

Copy link
Copy Markdown
Owner

Opening an image attached to a draft and closing it again (Escape, the close control, or a press outside) now returns the user to the draft with its words and picture.

The page comment card is an auto popover, and the platform's showModal dismisses every auto popover the dialog does not stand in, so opening the image viewer closed the card; after the viewer closed, focus fell to the body. This happened in Chrome, Firefox and WebKit. The words survived in storage, but the card was gone.

The platform reads a modal dialog's nesting from the tree, where a popover reads it from its source. showNativeLayer (keyboard/layer-stack.js) now takes a modal's source as well. For that opening it seats the dialog in the open popover that holds the control, as long as that popover stands within the dialog's home and so keeps the dialog's scoped styles. It returns the dialog home when it closes, and a popover that closes now closes the modals standing in it. The media viewer passes the image it was opened from.

The floating panel had the same symptom for a cause of its own: its document pointerdown read a press in the viewer as a press on the page and put away the thread view along with the reply being written. While a modal stands over the panel, a press now belongs to that modal (nativeModalAdmits).

A shadow-root popover still closes under the viewer, as it did before this change; the viewer can't move into a shadow tree without losing its styles, and no shipped shadow popover holds an image.

test_a_draft_s_image_closes_back_to_the_draft covers the card and the floating panel's thread reply through all three dismissals, and fails on each without its fix.

This was written by Claude Code on behalf of max-sixty

max-sixty and others added 3 commits October 14, 2026 11:31
… from it

Pressing a draft's attached image in the page comment card opened the image
viewer and closed the card: the card is an auto popover, and the platform's
modal entry dismisses every auto popover the dialog does not stand in. Closing
the viewer by Escape, its close button or a press outside then left the user on
the page with the card gone and focus on the body, in Chrome, Firefox and
WebKit alike. The draft itself was kept in storage.

The platform reads a modal dialog's nesting from the tree, where a popover's
comes from its `source`. `showNativeLayer` now takes a modal's `source` too:
it seats the dialog in the open popover holding that control, in the dialog's
own tree, for that opening, and returns it home as it closes. The media viewer
passes the image it opened from, so the card stays open under the viewer and
the user lands back on the thumbnail beside their words. Any other modal opened
with a source inside a popover behaves the same.

The new browser test covers the three dismissals and Escape returning to the
card afterwards.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…pover, and keep the floating panel's thread under the viewer

Review of the first change found three cases it got wrong:

- An authored popover holding an image link took the viewer out of the chrome's
  `@scope`, so it opened unstyled. A modal now joins only a popover standing
  within its own home, and opens at home otherwise, as before.
- A covering transition that dismissed the page comment card left the viewer
  modal inside a hidden card. A popover closing now closes the modals standing
  in it, as it does its nested popovers.
- In the floating panel, a press in the viewer read as a press on the page and
  put away the thread view with the reply being written. A press while a modal
  stands over the panel is now that modal's (`nativeModalAdmits`).

The browser test now covers the floating panel's thread reply beside the card.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@max-sixty
max-sixty merged commit 4e74362 into main Oct 14, 2026
2 of 3 checks passed
@max-sixty
max-sixty deleted the draft-survives-image-preview branch October 14, 2026 19:20
max-sixty added a commit that referenced this pull request Oct 15, 2026
The new `review-a-fix` example puts `lf-trace-compare` to work on a real
task. It holds one Playwright journey recorded twice: write a page
comment, paste a screenshot, open its preview, press Escape. The first
recording runs on Leaf with #2882's fix reverted, the second on Leaf
with it. Three keyed moments pair the two recordings, so choosing a
moment in either moves the other to its own capture of that step. At
"Back from the preview" they differ: before the fix the comment is gone,
and after it the comment is back with focus on its thumbnail. A
ship-or-hold ask and the cause follow.

## lf-trace-compare check

I exercised the fixture by pointer, keyboard (arrow keys on the chooser,
Enter on a moment) and touch. Pairing works as the registry describes,
including a peer that is hidden or was moved by hand. I found one
defect: a recording wrapped in a `<figure>` kept its margins while
hidden. Choosing After then moved the shown recording down by those
margins, and the sticky chooser hung over a blank band below the
workspace. The fix is in the playwright `theme.css`: every view, and a
recording inside one, now takes no block margin in the workspace.
`test_trace_comparison_shows_each_wrapped_recording_in_one_place` fails
without it.

## Large trace manifests live in leaf-assets

Each imported manifest is about 600 KB, mostly saved accessibility
trees, which is too large for the tree and for
`examples/corpus.data.json`. Both manifests are published to
`max-sixty/leaf-assets` under `examples/traces/`, beside their archives
and the trace media. A `$captures` entry now accepts `asset` in place of
`file` to read a pinned file, and `"format": "json"` to parse it
(`dev/leaf_dev/example_data.py`, `capture_file`). The corpus keeps the
capture as a reference. `wt refresh-previews` added the catalog still
and moved the pin.

> _This was written by Claude Code on behalf of max-sixty_

---------

Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
leaf-agent added a commit that referenced this pull request Nov 22, 2026
The transcript named tests/browser/test_comment_images.py, which has
never existed. It now shows output captured from #2882's own regression
test, test_a_draft_s_image_closes_back_to_the_draft, run at that fix's
commit (4e74362) with its runtime files set back to their parent's
(2 failed, focus assertion) and then restored (2 passed). The coverage
sentence now claims only what that run shows: the test fails in both
editors without the fix.
leaf-agent added a commit that referenced this pull request Nov 22, 2026
…-fix (#6721)

`test_every_idiom_in_the_catalog_stands_in_a_corpus_source` has failed
on main since #6715. That change moved the terminal-session idiom from
the `reading` package into Leaf's own registry as `pre.lf-terminal`, and
the test checks every idiom in that registry. No example had ever held
the idiom: #6542 added it to `reading`, which this test doesn't read.
The fix-review example (`examples/review-a-fix.html`) says its
regression test "fails on each without the fix" but showed no run. It
now shows that run as a terminal session: output captured from the fix's
own regression test, `test_a_draft_s_image_closes_back_to_the_draft`,
run at #2882's commit with its runtime files set back to their parent's
(2 failed) and then restored (2 passed). So the page carries the
evidence for its claim and the idiom has a corpus source.

The test fails on `b54a16fc4` with `no example holds pre.lf-terminal`
and passes on this branch. `leaf page check` on the example's page
directory reports no findings. The render check couldn't launch Chrome
in the triage sandbox, so this PR's corpus render tests are the first
browser draw of the new figure. The figure sits below the recordings, so
it shouldn't change the page's first screen, but the site previews
haven't been regenerated.

The other failure in [run
44982643983](https://github.com/max-sixty/leaf/actions/runs/44982643983),
`test_a_coarse_pointer_keeps_useful_status_without_keyboard_hints`, was
fixed by #6717, which merged after that run's commit.

Refs #6719 — automated triage

---------

Co-authored-by: leaf-agent <[email protected]>
Co-authored-by: leaf-agent <[email protected]>
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.

2 participants