Skip to content

Commit 5a979b0

Browse files
committed
Quick fix
1 parent 78598e2 commit 5a979b0

1 file changed

Lines changed: 13 additions & 7 deletions

File tree

src/components/datagrid/body/header/data_grid_header_cell_wrapper.tsx

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,20 +49,26 @@ export const EuiDataGridHeaderCellWrapper: FunctionComponent<
4949
}, [index, setFocusedCell]);
5050

5151
const [isFocused, setIsFocused] = useState(false);
52-
useEffect(() => {
53-
onFocusUpdate([index, -1], (isFocused: boolean) => {
54-
setIsFocused(isFocused);
55-
});
56-
}, [index, onFocusUpdate]);
5752

58-
useEffect(() => {
53+
const updateFocus = (isFocused: Boolean, headerEl: HTMLDivElement | null) => {
5954
if (isFocused && headerEl) {
6055
// Only focus the cell if not already focused on something in the cell
6156
if (!headerEl.contains(document.activeElement)) {
6257
headerEl.focus();
6358
}
6459
}
65-
}, [isFocused, headerEl]);
60+
}
61+
62+
useEffect(() => {
63+
onFocusUpdate([index, -1], (isFocused: boolean) => {
64+
setIsFocused(isFocused);
65+
updateFocus(isFocused, headerEl);
66+
});
67+
}, [index, onFocusUpdate]);
68+
69+
useEffect(() => {
70+
updateFocus(isFocused, headerEl);
71+
}, [headerEl]);
6672

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

0 commit comments

Comments
 (0)