Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[EuiDataGrid] On pagination, focus is not properly restored to a valid data grid cell #5577

Closed
cee-chen opened this issue Jan 28, 2022 · 0 comments · Fixed by #5578
Closed

Comments

@cee-chen
Copy link
Contributor

cee-chen commented Jan 28, 2022

Caught by @miukimiu in #5561 (review):

When clicking a pagination number the .euiDataGridBody outline appears and we see a black border on top of the pagination.
Screenshot 2022-01-28 at 12 55 00

This is occuring in Chrome, Firefox, and Safari - Safari just makes it more obvious because of its black outline.

Repro steps

Problem

This issue occurs due to the aria-controls property on our pagination component:

<div className="euiDataGrid__pagination">
<EuiTablePagination
aria-controls={controls}

Which, in our pagination component, we have some extra code that attempts to focus back onto the passed element, in this case our data grid:

if (ariaControls) {
const controlledElement = document.getElementById(ariaControls);
if (controlledElement) {
controlledElement.focus();
}
}

However, our data grid body has conditional tabIndex/onFocus logic which pagination does not know about:

const focusProps = useMemo<FocusProps>(
() =>
isFocusedCellInView
? {
// FireFox allows tabbing to a div that is scrollable, while Chrome does not
tabIndex: -1,
}
: {
tabIndex: 0,
onFocus: (e) => {

Solution

The solution here is to fire a manual setFocusedCell() API call onChangePage (which incidentally now also takes care of scrolling back upwards in the grid) instead of relying on aria-controls to focus onto the grid, due to our grid's complex focus behaivor.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant