Skip to content

[EuiDataGrid] Virtualization+scroll+keyboard focus combination bug #5517

@cee-chen

Description

@cee-chen

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:

  1. Go to https://elastic.github.io/eui/#/tabular-content/data-grid-virtualization
  2. Click the Columns toolbar button, then click it again to close it
  3. Press tab 3 times to focus into the grid. It should automatically focus onto the "Name" cell
  4. Click any visible non-sticky data cell (e.g. the first data cell)
  5. Press Tab and then Shift-Tab: notice that focus is restored to the data cell you clicked
  6. 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.
  7. 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:

  1. Leave it alone if it's an edge case 🤷‍♀️
  2. If a focused cell is no longer virtualized, attempt to set a new focus on whatever first cell is visible and focusable
  3. 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?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions