Here are the settings I’m passing to HOT, the onEdit() function is updating state outside and triggers a re-render of all cells (this is where I’d hope memoization would prevent unedited cells from re-rendering)
return {
width: ‘100%’,
height: ${tableHeight + emptySpace}px
,
rowHeights: rowsHeight,
colHeaders: true,
rowHeaderWidth:
(baseFieldsSettings &&
baseFieldsSettings.extraSmall &&
baseFieldsSettings.extraSmall.width) ||
44,
columnHeaderHeight: rowsHeight,
stretchH: StretchEnum.all,
autoColSize: false,
autoRowSize: false,
afterChange: (changes: Handsontable.CellChange[] | null, source: string) =>
onEdit(equipmentSectionIndex, changes),
currentRowClassName: ‘currentRow’,
manualColumnResize: true,
licenseKey,
enterMoves: () => {
if (tableRef && tableRef.current && tableRef.current.hotInstance) {
const selected = tableRef.current.hotInstance.getSelected();
const totalRows = tableRef.current.hotInstance.countRows();
const nextRow = selected[0][0] + 1;
const nextCol = selected[0][1] + 1;
if (nextRow === totalRows) {
// go to next column
const headerColumn = columns.find((_, colIndex) => colIndex === nextCol);
if (headerColumn && headerColumn.settings && headerColumn.settings.customRenderer) {
return { row: 0, col: 0 };
}
}
}
return { row: 1, col: 0 };
},
afterScrollVertically: () => {
if (tableRef && tableRef.current && tableRef.current.hotInstance) {
tableRef.current.hotInstance.destroyEditor();
}
},
afterScrollHorizontally: () => {
if (tableRef && tableRef.current && tableRef.current.hotInstance) {
tableRef.current.hotInstance.destroyEditor();
}
}
};
Any tips are welcome, thank you.