-
Notifications
You must be signed in to change notification settings - Fork 858
Description
Apologies for the nebulous title, this bug is a bit of an edge case so I'm not 100% sure how we want to attempt to solve it or even if we want to do so.
Repro steps:
- Go to https://elastic.github.io/eui/#/tabular-content/data-grid-virtualization
- Click the
Columns
toolbar button, then click it again to close it - Press tab 3 times to focus into the grid. It should automatically focus onto the "Name" cell
- Click any visible non-sticky data cell (e.g. the first data cell)
- Press Tab and then Shift-Tab: notice that focus is restored to the data cell you clicked
- Now with your mouse, scroll all the way to the middle or bottom of the grid. The cell you clicked should be long gone from the DOM due to virtualization.
- Now with your keyboard, press Tab (should be on pagination). Press Shift-Tab. Notice focus is no longer on any meaningful cell, and the arrow keys do nothing.
I think my reservations on how to fix this are mainly around the fact that I'm not sure if it's unexpected to have a user that relies on both mouse/scroll and keyboard nav/focus. With just keyboard nav alone, the user will be fine (after #5515 lands), and with mouse/scroll alone, the user is always fine. It's just this weird odd combination of both that can end up stranding the data grid's focus state.
So I guess with that in mind, here are some options I can think of:
- Leave it alone if it's an edge case 🤷♀️
- If a focused cell is no longer virtualized, attempt to set a new focus on whatever first cell is visible and focusable
- Or, if the user tabs into the grid and a focused cell was set but is no longer virtualized, always jump to that cell using react-window's
scrollToItem
API
Of those 3 options, I think I prefer 3 as the most straightforward and not potentially interfering with #5047. Thoughts @chandlerprall and @1Copenut?