Skip to content

Restore reply focus when a responsive target reappears #3558

Closed

Description

@leaf-agent

test_open_draft_retains_words_when_responsive_layout_hides_its_target[True] fails on current main: after a 480 px viewport hides #bg-contents a and a 1200 px viewport shows it again, the reply draft and its editor return, but the editor is no longer focused. The original responsive draft change specifically intended to retain focus and caret through this cycle.

Reproduce with uv run pytest -q 'tests/journeys/test_render_aim.py::test_open_draft_retains_words_when_responsive_layout_hides_its_target[True]'. The failure takes about 10 seconds locally. The editor still contains A reply about #bg-contents a and has a visible bounding box at the end.

Tracing thread-preview.js shows that placeThreadPreview saves a focus hold for the preview editor when the target hides. Before the target returns, a different reply editor receives focus outside the preview. The focus placement count advances, so the saved hold correctly declines to restore the older editor when the preview becomes visible. The missing behavior appears to be a handoff between the live reply's views when the target returns, rather than a change to the shared focus guard. Diagnostic code was removed from the checkout.

This was one of the failures in CI run 39766486203.

Activity

  1. leaf-agent commented on Oct 22, 2026

    @leaf-agent
    CollaboratorAuthor

    I reproduced the failing journey on current main. The reply retains its words and focus, but focus moves to the floating panel’s reply field while the target is hidden. After the target returns, both reply views are visible and the panel field remains focused. The assertion checks only the preview field, so it reports this as lost focus.

    The preview placement saves a focus hold, and the shared focus rule declines to return to it after another placement. That prevents a resize from taking focus away from the panel field the user can currently type in. The remaining product decision is whether returning the target should move the active reply back to its page card or keep the panel editor active; the current test requires the former. I left the issue open and made no focus-rule change pending that choice.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions