Don't scroll table element into view if focused by mouse click#2872
Open
Don't scroll table element into view if focused by mouse click#2872
Conversation
rajsite
reviewed
Feb 25, 2026
| @@ -0,0 +1,7 @@ | |||
| { | |||
Member
There was a problem hiding this comment.
@msmithNI you up for reviewing these changes to keyboard-navigation-manager?
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.
Pull Request
🤨 Rationale
An SLE user reported a bug where clicking on the horizontal scrollbar of a table (which itself was within a scrollable viewport) caused the containing scrollable viewport to scroll to the top of the table.
👩💻 Implementation
We have a bunch of special logic to make keyboard navigation within the table nice. This involves manually setting the focus on different subelements of the table (rows, menu buttons, cell content, column headers) in response to events like keystrokes and focus-ins. The reported buggy symptom is due to us focusing the first column header (or the last subelement that previously had focus) when the table gets focused. When you click a part of the table that isn't a cell, such as a scrollbar, or the empty space below the rows, that's what happens.
We still want to scroll the focused element into view if navigating by keyboard, so my fix is to set a flag whenever the table gets a
pointerdownevent and use that flag to suppress scrolling when callingfocus()on an element. This seems preferable to usingkeydown, since that would require detecting tab keypresses that occur outside the table (in addition to the ones within it). We clear the flag at the end of the table'sfocusinhandler, so subsequent keyboard navigation will continue to scroll elements into view as needed. It is only when the table gains focus from outside that we now suppress scrolling, and only when clicking.Note: I also did some refactoring of the keyboard navigation manager to help me better understand it. That is all captured in a separate commit, so I would recommend reviewing each commit separately.
🧪 Testing
Added test cases, and existing tests still pass.