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
4 changes: 0 additions & 4 deletions eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -574,10 +574,6 @@ export default [
{
name: '@testing-library/dom',
message: 'Import @testing-library/react instead.'
},
{
name: 'lodash',
message: 'Import lodash-es instead.'
}
],
'@typescript-eslint/no-shadow': 0,
Expand Down
15 changes: 4 additions & 11 deletions src/DataGrid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,6 @@ function DataGrid<R, SR, K extends Key>(
const [selectedPosition, setSelectedPosition] = useState(
(): SelectCellState | EditCellState<R> => ({ idx: -1, rowIdx: minRowIdx - 1, mode: 'SELECT' })
);
const [prevSelectedPosition, setPrevSelectedPosition] = useState(selectedPosition);

/**
* refs
Expand Down Expand Up @@ -484,20 +483,14 @@ function DataGrid<R, SR, K extends Key>(
*/
useLayoutEffect(() => {
if (
!selectedCellIsWithinSelectionBounds ||
isSamePosition(selectedPosition, prevSelectedPosition)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It does not look like check is needed

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Forgot to post this comment

focusSinkRef.current !== null &&
selectedCellIsWithinSelectionBounds &&
selectedPosition.idx === -1
) {
setPrevSelectedPosition(selectedPosition);
return;
}

setPrevSelectedPosition(selectedPosition);

if (focusSinkRef.current !== null && selectedPosition.idx === -1) {
focusSinkRef.current.focus({ preventScroll: true });
scrollIntoView(focusSinkRef.current);
}
}, [selectedCellIsWithinSelectionBounds, selectedPosition, prevSelectedPosition]);
}, [selectedCellIsWithinSelectionBounds, selectedPosition]);

useLayoutEffect(() => {
if (shouldFocusCell) {
Expand Down