Skip to content
19 changes: 15 additions & 4 deletions src/components/datagrid/utils/focus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,21 @@ export const useFocus = ({
EuiDataGridFocusedCell | undefined
>(undefined);

const setFocusedCell = useCallback((focusedCell: EuiDataGridFocusedCell) => {
_setFocusedCell(focusedCell);
setIsFocusedCellInView(true); // scrolling.ts ensures focused cells are fully in view
}, []);
const setFocusedCell = useCallback(
(nextFocusedCell: EuiDataGridFocusedCell) => {
if (
focusedCell &&
nextFocusedCell[0] === focusedCell[0] &&
nextFocusedCell[1] === focusedCell[1]
) {
return;
}
Comment thread
Kerry350 marked this conversation as resolved.

_setFocusedCell(nextFocusedCell);
setIsFocusedCellInView(true); // scrolling.ts ensures focused cells are fully in view
},
[focusedCell]
);

const previousCell = useRef<EuiDataGridFocusedCell | undefined>(undefined);
useEffect(() => {
Expand Down