Skip to content

Disarm Escape's Tab exit on click or blur - #467

Merged
jserv merged 1 commit into
sysprog21:mainfrom
TKkusa:escape-tab-after-click
Oct 25, 2026
Merged

jserv merged 1 commit into
sysprog21:mainfrom
TKkusa:escape-tab-after-click

Conversation

@TKkusa

@TKkusa TKkusa commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

Escape in the editor arms the next Tab to leave it, and only the editor's next keydown disarmed that. A click back into the editor, or focus leaving and coming back by keyboard, such as clicking Run tests and pressing Tab to return, left it armed, so the next Tab moved focus to the test drawer's resize handle instead of indenting. This also clears the flag on the editor's pointerdown and blur. Escape followed directly by Tab or Shift+Tab still leaves the editor, since neither event fires between those keys, and the existing assertion for that path in tests/browser/editor-pipeline.test.js still passes.

The two new browser tests sit beside it, one per event: a click back into the editor after Escape, and focus leaving and returning without a click. Each fails on main, each fails again when only its own event is removed from the listener loop, and both pass with the change.

Validation: node --test tests/browser/editor-pipeline.test.js passes 47 of 47 with none skipped, and ./scripts/test.sh passes with no failed gate on this tree. By hand in Chrome 155.0.8059.85, the steps in #465 leave the editor on b0059b2 built from source and indent with this change. Not checked locally: the Java runner's browser tests (no JDK), cargo-audit, actionlint, ruff, commentflow and shfmt; none of them covers the two changed files.

Screenshots from Chrome 155.0.8059.85 on builds from source, b0059b2 first and this branch second, with DevTools logging keydown, pointerdown and blur on the editor and focusin on the document; the snippet only logs and sits at the top of each console. On b0059b2, the Tab after Escape and a click back into the editor blurs the editor and focus lands on #test-drawer-resizer; the SUMMARY and #results-toggle lines are further Tab presses after focus had left. With this change, the same Escape and click are followed by five Tab presses that all stay on #editor; its last two lines came after them, when I switched to the screenshot tool and back. The two runs used different problems, which the key handling does not depend on.

Before, on b0059b2 Before, on b0059b2: after Escape and a click back into the editor, Tab blurs it and focus moves to #test-drawer-resizer After, with this change After, with this change: after Escape and a click back into the editor, five Tab presses all stay on #editor

#456 also edits this keydown handler, at the top of the function rather than around the flag, so whichever merges second needs at most a trivial rebase.

Closes #465

Escape arms the next Tab to move focus out of the editor, and only the
editor's next keydown disarmed it. A click back into the editor, or
focus leaving and returning by keyboard, fires no keydown there, so the
next Tab still left the editor instead of indenting. Clearing the flag
on pointerdown and blur ends the arm once the candidate is editing again
or has already left, while Escape followed directly by Tab or Shift+Tab
stays the keyboard way out, since neither event fires between those
keys.

Closes sysprog21#465
@jserv

jserv commented Oct 24, 2026

Copy link
Copy Markdown
Contributor

Add screenshots to the pull request description to illustrate your work, as @ColtenOuO suggests. Example: #349

@jserv
jserv requested review from ColtenOuO and alanhc October 24, 2026 12:19
@TKkusa

TKkusa commented Oct 24, 2026

Copy link
Copy Markdown
Contributor Author

The description now has before and after screenshots: Google Chrome with a DevTools log of the editor's key, pointer and focus events, on b0059b2 and on this branch.

@ColtenOuO ColtenOuO left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@jserv
jserv merged commit 4e18efc into sysprog21:main Oct 25, 2026
11 checks passed
@jserv

jserv commented Oct 25, 2026

Copy link
Copy Markdown
Contributor

Thank @TKkusa for contributing!

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.

Tab still leaves the editor after Escape and a click back in

3 participants