AdvancedTable focus bug fix - #4017
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
@zamoore can you provide links/references to where this bug was introduced (in the PR description)? in this way we can compare the before/after and have more context about the fix itself |
7036014 to
3a6e608
Compare
| "@hashicorp/design-system-components": patch | ||
| --- | ||
|
|
||
| `AdvancedTable` - Fixed an issue where clicking a cell scrolled the page to center that cell |
There was a problem hiding this comment.
[todo] Add start and end comments around entry
didoo
left a comment
There was a problem hiding this comment.
There is something that I don't understand: I checked out the code at this PR merge #3818 and run the showcase; when I click on a cell inside the AdvancedTable, nothing happens (there is no movement of the scrolled table, no centering of the clicked cell).
This tells me that between then and now, a core behaviour of the AdvancedTable has been changed (but I don't see mention of this change in the version history of the component). Now the table "centers" the clicked cell, which is something... unexpected, as a user. Why do we infer that, if I click a cell, I also intend to center it in the table? This is an assumption that we're making, and I am not sure it's expected (I checked other data tables implementations, and I could not find similar behaviour) expecially because it shifts the visual position of the content and is really disorienting.
I would challenge this implementation (sorry I didn't notice before) and would consider removing entirely this "feature" (and with this, also avoid the bug).
@didoo this feature is needed for keyboard users. without the scrolling behavior, your focus can be outside of the view which is a wcag failure. I believe this was introduced when we switched to the composite component. as for other workarounds, one option @zamoore and I talked about was to add a check to the scrolling function that checks if the focus event was initiated by the cursor or keyboard. If it is keyboard initiated, then do the scroll. otherwise, ignore. does that option seem better to you? |
@didoo @shleewhite - Yes, that is correct. It wasn't explicitly a feature added to the Edit: Ah, you're saying that the bug is not present in #3818 . That's interesting. I'm not certain what else would have changed between then and now? |
Yes, that's what I meant (hence the use of the word |
|
@didoo @shleewhite - I updated the code to only react to keyboard events |
didoo
left a comment
There was a problem hiding this comment.
There may be an issue (?) with sticky header/columns, where the cell focused via keyboard is not visible (it's behind the sticky header/column):
Screen.Recording.2026-07-29.at.09.18.27.mov
No idea how (and even if) this can be solved.
|
I found this while testing the resizing PR #4020 but it might be more related to this; traversing the grid with arrow keys works fine until I sort a column, which then seems to keep the same focus order but results in jumping around because the focus order is different from the visual order of the cells in the column. Is this a known issue already or expected?
|
This isn't related, but it's also not a known issue. Can you create a ticket so we can address it on its own? Good find |


📌 Summary
Clicking a cell in
AdvancedTablemade the page jump. Removes thecenterscroll alignment onTd/Thso focus scrolls by the minimum distance instead.🛠️ Detailed description
Cells are
Compositeitems with atabindexso clicking one focuses it and fireshdsScrollIntoViewOnFocus. That modifier was passedblock="center" inline="center", andscrollIntoViewwalks up every scroll ancestor including the document, socenterrecentered the whole page even when the cell was already visible.Dropping the override falls back to the default
nearestbehavior.Background
The bug was introduced in #3818 when we switched keyboard navigation to use the Composite component.
🔗 External links
Jira ticket: HDS-6545
👀 Component checklist
💬 Please consider using conventional comments when reviewing this PR.
📋 PCI review checklist
Examples of changes to controls include access controls, encryption, logging, etc.
Examples include changes to operating systems, ports, protocols, services, cryptography-related components, PII processing code, etc.