Conversation
| const initialActivePosition: ActivePosition = { | ||
| idx: -1, | ||
| // use -Infinity to avoid issues when adding header rows or top summary rows | ||
| rowIdx: Number.NEGATIVE_INFINITY, |
There was a problem hiding this comment.
Found a bug and added a test.
| } | ||
|
|
||
| return { | ||
| activePosition: resolvedActivePosition, |
There was a problem hiding this comment.
We will now render DataGrid with the correct state one render early in some cases.
We could also just not do this to keep the implementation simpler.
|
|
||
| import type { CalculatedColumn, Position, StateSetter } from '../types'; | ||
|
|
||
| interface ActivePosition extends Position { |
There was a problem hiding this comment.
Renamed this from ActiveCellState to ActivePosition, likewise for EditPosition below
| if (!activePositionIsCellInViewport) return; | ||
| const { idx, rowIdx } = activePosition; | ||
| onCellCopy?.({ row: rows[rowIdx], column: columns[idx] }, event); | ||
| onCellCopy?.({ row: getActiveRow(), column: getActiveColumn() }, event); |
There was a problem hiding this comment.
WDYT about getActiveRow()/getActiveColumn()? Worth it?
There was a problem hiding this comment.
Not sure. Should we return variables instead activeRow, activeColumn?
There was a problem hiding this comment.
We'd have to check if they're undefined in many places
There was a problem hiding this comment.
Could also add queryActive*() 🤔
|
|
||
| function getDragHandle() { | ||
| if (onFill == null || activePosition.mode === 'EDIT' || !activePositionIsCellInViewport) { | ||
| if (onFill == null || activePosition.mode !== 'ACTIVE' || !activePositionIsCellInViewport) { |
There was a problem hiding this comment.
I've changed the mode check in case we ever add a third mode
| await validateCellPosition(2, 0); | ||
| }); | ||
|
|
||
| test('adding a top summary row when no rows or cells are active should not focus the summary row', async () => { |
There was a problem hiding this comment.
Not sure where to put this test, it's not only strictly about keyboard navigation, and it may not be limited to TreeDataGrid if we ever add row focus support in DataGrid.
There was a problem hiding this comment.
TreeDataGrid tests also have some keyboard tests so we can move it there as well. I am okay with either
https://github.com/Comcast/react-data-grid/blob/main/test/browser/TreeDataGrid.test.tsx#L311
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #3990 +/- ##
==========================================
- Coverage 97.51% 97.41% -0.11%
==========================================
Files 36 37 +1
Lines 1449 1470 +21
Branches 463 471 +8
==========================================
+ Hits 1413 1432 +19
- Misses 36 38 +2
🚀 New features to boost your workflow:
|
src/hooks/useActivePosition.ts
Outdated
| export function useActivePosition<R, SR>({ | ||
| columns, | ||
| rows, | ||
| validatePosition, |
There was a problem hiding this comment.
Would it make sense for this hook to return validatePosition?
| if (!activePositionIsCellInViewport) return; | ||
| const { idx, rowIdx } = activePosition; | ||
| onCellCopy?.({ row: rows[rowIdx], column: columns[idx] }, event); | ||
| onCellCopy?.({ row: getActiveRow(), column: getActiveColumn() }, event); |
There was a problem hiding this comment.
Not sure. Should we return variables instead activeRow, activeColumn?
| await validateCellPosition(2, 0); | ||
| }); | ||
|
|
||
| test('adding a top summary row when no rows or cells are active should not focus the summary row', async () => { |
There was a problem hiding this comment.
TreeDataGrid tests also have some keyboard tests so we can move it there as well. I am okay with either
https://github.com/Comcast/react-data-grid/blob/main/test/browser/TreeDataGrid.test.tsx#L311
No description provided.