Skip to content

[EuiDataGrid] Fix focus on pagination#5578

Merged
cee-chen merged 5 commits intoelastic:mainfrom
cee-chen:datagrid/5577
Jan 28, 2022
Merged

[EuiDataGrid] Fix focus on pagination#5578
cee-chen merged 5 commits intoelastic:mainfrom
cee-chen:datagrid/5577

Conversation

@cee-chen
Copy link
Copy Markdown
Contributor

@cee-chen cee-chen commented Jan 28, 2022

Summary

closes #5577 - please see the linked issue for a description of why the bug is happening.

Before

Notice the black outline (in Safari) that indicates the grid wrapper is getting focused instead of into a grid cell.

before

After

Notice that the first grid data cell is now focused on every new page.

after

Checklist

- [ ] Check against all themes for compatibility in both light and dark modes
- [ ] Checked in mobile

  • Checked in Chrome, Safari, Edge, and Firefox

- [ ] Props have proper autodocs and playground toggles
- [ ] Added documentation
- [ ] Checked Code Sandbox works for any docs examples

- [ ] Checked for breaking changes and labeled appropriately

  • Checked for accessibility including keyboard-only and screenreader modes
  • A changelog entry exists and is marked appropriately

- Currently the grid is sort of brokenly doing this due to `aria-controls` - we should just fix the buggy behavior and make this call manually
- as of recent scrolling/focus fixes, setFocusedCell will automatically scroll to the targeted cell
@cee-chen cee-chen requested a review from 1Copenut January 28, 2022 20:49
@cee-chen
Copy link
Copy Markdown
Contributor Author

cee-chen commented Jan 28, 2022

@1Copenut would love your eyes/testing on this and confirmation that this is indeed best keyboard/screen reader practice. I would have thought taking focus away from the pagination buttons would not be great, but it looks like we baked that logic into our pagination controls prop (see #5577) so I assume it's best practice.

FWIW, the screen reader experience from this is now also the same as when the user uses the page up/page down keys on the grid

@kibanamachine
Copy link
Copy Markdown

Preview documentation changes for this PR: https://eui.elastic.co/pr_5578/

Copy link
Copy Markdown
Contributor

@1Copenut 1Copenut left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👏 LGTM! I tested the branch locally with Safari and it worked really well. The focus was captured, and it read back the current cell information and new page N of NN. This will be a big boost for assistive technology and keyboard navigation. Thank you @constancecchen

@cee-chen
Copy link
Copy Markdown
Contributor Author

Awesome, thanks a million Trevor!!

@cee-chen cee-chen merged commit 4b42a54 into elastic:main Jan 28, 2022
@cee-chen cee-chen deleted the datagrid/5577 branch January 28, 2022 23:44
gdimitropoulos pushed a commit to gdimitropoulos/eui that referenced this pull request Apr 21, 2022
* Manually focus into the first data cell on pagination change

- Currently the grid is sort of brokenly doing this due to `aria-controls` - we should just fix the buggy behavior and make this call manually

* Remove now-unnecessary gridRef/scrollToItem call

- as of recent scrolling/focus fixes, setFocusedCell will automatically scroll to the targeted cell

* Add pagination unit tests

* [misc] clean up unused pagination prop type

* Changelog
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

3 participants