fix: keep the editor typable after clicking a highlighted lint - #3834
Open
mvanhorn wants to merge 1 commit into
Open
fix: keep the editor typable after clicking a highlighted lint#3834mvanhorn wants to merge 1 commit into
mvanhorn wants to merge 1 commit into
Conversation
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.
Issues
Fixes #3721
Description
Root cause: in
SuggestionBox.tstheFocusHookattached to the first suggestion button callsnode.focus()on every popup open, moving keyboard focus off the editor and onto a<button>(which cannot accept typed text). Escape works becauseCloseOnEscapeHookcloses the popup and restores the saved cursor. The fix is to only auto-focus a suggestion when the popup was opened via the keyboard activation key (double-tap shift/control ->openClosestToCaret), and NOT when it was opened by a pointer click (onPointerDown).PopupHandlerwill track which path opened the popup and thread anautofocusSuggestionflag throughrender()->SuggestionBox()->suggestions(), so theFocusHookis only wired for keyboard-opened popups. Because the highlight render box usespointer-events: none, a click lands in the underlying editor element (thepointerdownlistener source), so leaving focus there keeps the caret positioned where the user clicked and Delete/typing work immediately, while keyboard-opened popups retain focus for arrow/enter navigation and Escape still restores the cursor.Demo
N/A - behavioral fix; validated by the tests below.
How Has This Been Tested?
document.activeElementis the textarea).AI Disclosure
Checklist