Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion changelogs/upcoming/7698.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
**Bug fixes**

- Fixed a focus bug with `EuiDataGrid`s with `leadingControlColumns` when moving columns to the left/right
- Fixed a focus bug with `EuiDataGrid`s with `leadingControlColumns` when moving columns to the left/right ([#7701](https://github.com/elastic/eui/pull/7701))
Original file line number Diff line number Diff line change
Expand Up @@ -52,17 +52,14 @@ export const EuiDataGridHeaderCellWrapper: FunctionComponent<
useEffect(() => {
onFocusUpdate([index, -1], (isFocused: boolean) => {
setIsFocused(isFocused);
});
}, [index, onFocusUpdate]);

useEffect(() => {
if (isFocused && headerEl) {
// Only focus the cell if not already focused on something in the cell
if (!headerEl.contains(document.activeElement)) {
headerEl.focus();
if (isFocused && headerEl) {
// Only focus the cell if not already focused on something in the cell
if (!headerEl.contains(document.activeElement)) {
headerEl.focus();
}
}
}
}, [isFocused, headerEl]);
});
}, [index, onFocusUpdate, headerEl]);

// For cell headers with actions, auto-focus into the button instead of the cell wrapper div
// The button text is significantly more useful to screen readers (e.g. contains sort order & hints)
Expand Down