Skip to content

Commit

Permalink
fix: case table enter key advances to next row [PT-187967544] (#1362)
Browse files Browse the repository at this point in the history
  • Loading branch information
kswenson authored Jul 20, 2024
1 parent 61ed699 commit e6f2bb4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion v3/src/components/case-table/collection-table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ export const CollectionTable = observer(function CollectionTable(props: IProps)
args.onClose(true)
// prevent RDG from handling the event
event.preventGridDefault()
navigateToNextRow()
navigateToNextRow(event.shiftKey)
}
}

Expand Down
11 changes: 7 additions & 4 deletions v3/src/components/case-table/use-selected-cell.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,16 @@ export function useSelectedCell(gridRef: React.RefObject<DataGridHandle | null>,
: undefined
}, [])

const navigateToNextRow = useCallback(() => {
const navigateToNextRow = useCallback((back = false) => {
if (selectedCell.current?.columnId) {
const idx = columns.findIndex(column => column.key === selectedCell.current?.columnId)
const rowIdx = selectedCell.current.rowIdx + 1
const rowIdx = Math.max(0, selectedCell.current.rowIdx + (back ? -1 : 1))
const position = { idx, rowIdx }
gridRef.current?.selectCell(position, true)
collectionTableModel?.scrollRowIntoView(rowIdx)
// setTimeout so it occurs after handling of current event completes
setTimeout(() => {
collectionTableModel?.scrollRowIntoView(rowIdx)
gridRef.current?.selectCell(position, true)
})
}
}, [collectionTableModel, columns, gridRef])

Expand Down

0 comments on commit e6f2bb4

Please sign in to comment.