Created
December 3, 2024 02:53
-
-
Save romgrk/7f7a682578a1c5f2bbcd8b82aef3148e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const focusedVirtualCellSelector = createSelectorMemoizedV8( | |
gridRenderContextSelector, | |
gridFocusCellSelector, | |
currentRowsSelector, | |
visibleColumnsSelector, | |
(currentRenderContext, focusedCell, currentRows, visibleColumns) => { | |
if (!focusedCell) { | |
return null; | |
} | |
const rowIndex = currentRows.findIndex((row) => row.id === focusedCell.id); | |
const columnIndex = visibleColumns.findIndex((column) => column.field === focusedCell.field); | |
if (rowIndex === -1 || columnIndex === -1) { | |
return null; | |
} | |
const isFocusedCellInContext = | |
rowIndex >= currentRenderContext.firstRowIndex && | |
rowIndex <= currentRenderContext.lastRowIndex && | |
columnIndex >= currentRenderContext.firstColumnIndex && | |
columnIndex <= currentRenderContext.lastColumnIndex; | |
if (isFocusedCellInContext) { | |
return null; | |
} | |
return { | |
...focusedCell, | |
rowIndex, | |
columnIndex, | |
}; | |
}, | |
); | |
// usage | |
const focusedVirtualCell = useGridSelectorV8(apiRef, focusedVirtualCellSelector) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment