-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Update eslint deps #3615
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update eslint deps #3615
Changes from all commits
1ae3d7f
902d96d
2141ff4
5878ec9
6fcc3fc
3245e76
0680367
ca70f3b
61a661e
d6eb0dd
c5b8f74
706019a
8438db8
a3d1f21
9ca5f15
5ce5789
6c45583
aad8f92
6fd1524
222e2c9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -296,6 +296,8 @@ function DataGrid<R, SR, K extends Key>( | |
| const [isDragging, setDragging] = useState(false); | ||
| const [draggedOverRowIdx, setOverRowIdx] = useState<number | undefined>(undefined); | ||
| const [scrollToPosition, setScrollToPosition] = useState<PartialPosition | null>(null); | ||
| const [shouldFocusCell, setShouldFocusCell] = useState(false); | ||
| const [previousRowIdx, setPreviousRowIdx] = useState(-1); | ||
|
|
||
| const getColumnWidth = useCallback( | ||
| (column: CalculatedColumn<R, SR>) => { | ||
|
|
@@ -338,15 +340,13 @@ 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 | ||
| */ | ||
| const prevSelectedPosition = useRef(selectedPosition); | ||
| const latestDraggedOverRowIdx = useRef(draggedOverRowIdx); | ||
| const lastSelectedRowIdx = useRef(-1); | ||
| const focusSinkRef = useRef<HTMLDivElement>(null); | ||
| const shouldFocusCellRef = useRef(false); | ||
|
Comment on lines
-345
to
-349
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Removed a few refs |
||
|
|
||
| /** | ||
| * computed values | ||
|
|
@@ -458,31 +458,50 @@ function DataGrid<R, SR, K extends Key>( | |
| selectCell({ rowIdx: minRowIdx + rowIdx - 1, idx }); | ||
| }); | ||
|
|
||
| /** | ||
| * callbacks | ||
| */ | ||
| const setDraggedOverRowIdx = useCallback((rowIdx?: number) => { | ||
| setOverRowIdx(rowIdx); | ||
| latestDraggedOverRowIdx.current = rowIdx; | ||
| }, []); | ||
|
|
||
| const focusCellOrCellContent = useCallback(() => { | ||
| const cell = getCellToScroll(gridRef.current!); | ||
| if (cell === null) return; | ||
|
|
||
| scrollIntoView(cell); | ||
| // Focus cell content when available instead of the cell itself | ||
| const elementToFocus = cell.querySelector<Element & HTMLOrSVGElement>('[tabindex="0"]') ?? cell; | ||
| elementToFocus.focus({ preventScroll: true }); | ||
| }, [gridRef]); | ||
|
|
||
| /** | ||
| * effects | ||
| */ | ||
| useLayoutEffect(() => { | ||
| if ( | ||
| !selectedCellIsWithinSelectionBounds || | ||
| isSamePosition(selectedPosition, prevSelectedPosition.current) | ||
| isSamePosition(selectedPosition, prevSelectedPosition) | ||
| ) { | ||
| prevSelectedPosition.current = selectedPosition; | ||
| setPrevSelectedPosition(selectedPosition); | ||
| return; | ||
| } | ||
|
|
||
| prevSelectedPosition.current = selectedPosition; | ||
| setPrevSelectedPosition(selectedPosition); | ||
|
|
||
| if (selectedPosition.idx === -1) { | ||
| focusSinkRef.current!.focus({ preventScroll: true }); | ||
| if (focusSinkRef.current !== null && selectedPosition.idx === -1) { | ||
| focusSinkRef.current.focus({ preventScroll: true }); | ||
| scrollIntoView(focusSinkRef.current); | ||
| } | ||
| }); | ||
| }, [selectedCellIsWithinSelectionBounds, selectedPosition, prevSelectedPosition]); | ||
|
|
||
| useLayoutEffect(() => { | ||
| if (!shouldFocusCellRef.current) return; | ||
| shouldFocusCellRef.current = false; | ||
| focusCellOrCellContent(); | ||
| }); | ||
| if (shouldFocusCell) { | ||
| setShouldFocusCell(false); | ||
| focusCellOrCellContent(); | ||
| } | ||
| }, [shouldFocusCell, focusCellOrCellContent]); | ||
|
|
||
| useImperativeHandle(ref, () => ({ | ||
| element: gridRef.current, | ||
|
|
@@ -499,14 +518,6 @@ function DataGrid<R, SR, K extends Key>( | |
| selectCell | ||
| })); | ||
|
|
||
| /** | ||
| * callbacks | ||
| */ | ||
| const setDraggedOverRowIdx = useCallback((rowIdx?: number) => { | ||
| setOverRowIdx(rowIdx); | ||
| latestDraggedOverRowIdx.current = rowIdx; | ||
| }, []); | ||
|
|
||
| /** | ||
| * event handlers | ||
| */ | ||
|
|
@@ -536,9 +547,8 @@ function DataGrid<R, SR, K extends Key>( | |
| if (isRowSelectionDisabled?.(row) === true) return; | ||
| const newSelectedRows = new Set(selectedRows); | ||
| const rowKey = rowKeyGetter(row); | ||
| const previousRowIdx = lastSelectedRowIdx.current; | ||
| const rowIdx = rows.indexOf(row); | ||
| lastSelectedRowIdx.current = rowIdx; | ||
| setPreviousRowIdx(rowIdx); | ||
|
|
||
| if (checked) { | ||
| newSelectedRows.add(rowKey); | ||
|
|
@@ -758,7 +768,7 @@ function DataGrid<R, SR, K extends Key>( | |
| // Avoid re-renders if the selected cell state is the same | ||
| scrollIntoView(getCellToScroll(gridRef.current!)); | ||
| } else { | ||
| shouldFocusCellRef.current = true; | ||
| setShouldFocusCell(true); | ||
| setSelectedPosition({ ...position, mode: 'SELECT' }); | ||
| } | ||
|
|
||
|
|
@@ -870,16 +880,6 @@ function DataGrid<R, SR, K extends Key>( | |
| return isDraggedOver ? selectedPosition.idx : undefined; | ||
| } | ||
|
|
||
| function focusCellOrCellContent() { | ||
| const cell = getCellToScroll(gridRef.current!); | ||
| if (cell === null) return; | ||
|
|
||
| scrollIntoView(cell); | ||
| // Focus cell content when available instead of the cell itself | ||
| const elementToFocus = cell.querySelector<Element & HTMLOrSVGElement>('[tabindex="0"]') ?? cell; | ||
| elementToFocus.focus({ preventScroll: true }); | ||
| } | ||
|
|
||
| function renderDragHandle() { | ||
| if ( | ||
| onFill == null || | ||
|
|
@@ -925,7 +925,7 @@ function DataGrid<R, SR, K extends Key>( | |
| const colSpan = getColSpan(column, lastFrozenColumnIndex, { type: 'ROW', row }); | ||
|
|
||
| const closeEditor = (shouldFocusCell: boolean) => { | ||
| shouldFocusCellRef.current = shouldFocusCell; | ||
| setShouldFocusCell(shouldFocusCell); | ||
| setSelectedPosition(({ idx, rowIdx }) => ({ idx, rowIdx, mode: 'SELECT' })); | ||
| }; | ||
|
|
||
|
|
@@ -1061,6 +1061,7 @@ function DataGrid<R, SR, K extends Key>( | |
| // Reset the positions if the current values are no longer valid. This can happen if a column or row is removed | ||
| if (selectedPosition.idx > maxColIdx || selectedPosition.rowIdx > maxRowIdx) { | ||
| setSelectedPosition({ idx: -1, rowIdx: minRowIdx - 1, mode: 'SELECT' }); | ||
| // eslint-disable-next-line react-compiler/react-compiler | ||
| setDraggedOverRowIdx(undefined); | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this needed? We do set it to undefined after the drag operation
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is it possible that the rows update while we're dragging?
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Probably. I added it back for now. I will look into alternatives
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Mmh, setting ref during render?
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, need a workaround. We need ref to access the latest value. I will investigate |
||
| } | ||
|
|
||
|
|
@@ -1182,6 +1183,7 @@ function DataGrid<R, SR, K extends Key>( | |
| ); | ||
| })} | ||
| <RowSelectionChangeProvider value={selectRowLatest}> | ||
| {/* eslint-disable-next-line react-compiler/react-compiler */} | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Don't know which line it is complaining about
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Probably the
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I tried removing it and it was still showing the same warning |
||
| {getViewportRows()} | ||
| </RowSelectionChangeProvider> | ||
| {bottomSummaryRows?.map((row, rowIdx) => { | ||
|
|
@@ -1245,7 +1247,7 @@ function DataGrid<R, SR, K extends Key>( | |
| <ScrollToCell | ||
| scrollToPosition={scrollToPosition} | ||
| setScrollToCellPosition={setScrollToPosition} | ||
| gridElement={gridRef.current!} | ||
| gridRef={gridRef} | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| /> | ||
| )} | ||
| </div> | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -36,6 +36,7 @@ export function useViewportColumns<R, SR>({ | |
|
|
||
| const updateStartIdx = (colIdx: number, colSpan: number | undefined) => { | ||
| if (colSpan !== undefined && colIdx + colSpan > colOverscanStartIdx) { | ||
| // eslint-disable-next-line react-compiler/react-compiler | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should open an issue |
||
| startIdx = colIdx; | ||
| return true; | ||
| } | ||
|
|
||

There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I removed the eslint-plugin. Not sure why is it failing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like the plugin needs to export
Plugin, manually tweaking the declaration files fixes it.Composite projects require declaration files to be emitted, and TS can't emit a declaration file without access to the
Plugintype from the@tanstack/eslint-plugin-router.Should open an issue.