Repository navigation
Keep a control's focus when the settings dialog opens - #20
Merged
Merged
Conversation
The model settings dialog moves focus to its heading on the frame after it
opens. When a control was focused before that frame, the late callback took
focus away from it. This made "refreshes resource estimates..." fail
intermittently in CI ("Received element with focus: <h2>") whenever the
estimate appeared before the frame. Move focus only if it has not changed
since opening, and cancel the frame when the dialog closes. A new test
covers both the untouched heading focus and a control focused first; before
the fix it failed deterministically with the CI error.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes the intermittent
ModelSettingsDialogCI failure seen on PR #18 ("Expected element with focus: <input …ctx_size>, Received: <h2 …-title>").Cause: on open the dialog schedules
requestAnimationFrame(() => heading.focus()). If a control is focused before that frame — the test focusesctx_sizeas soon as the first estimate renders, which sometimes happens within the first frame — the late callback steals focus. The same race applies to a user who focuses a control within the first frame.Fix: remember the focused element after
showModal()and move focus to the heading only if it is unchanged at the frame; cancel the frame when the dialog closes.Verification: a new test (heading focused when untouched; a control focused before the frame keeps focus) failed deterministically before the fix with the CI error and passes after it. Local: lint, typecheck, 1,455 frontend tests, and the affected tests repeated.
🤖 Generated with Claude Code