Skip to content

Commit

Permalink
fix: SURVEY-17202 reverting Grid.startCellEditing back (#330)
Browse files Browse the repository at this point in the history
  • Loading branch information
fspringveldt committed Jun 20, 2023
1 parent 843c56d commit c8a6509
Showing 1 changed file with 17 additions and 7 deletions.
24 changes: 17 additions & 7 deletions src/components/Grid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@ export const Grid = ({
setOnCellEditingComplete,
getColDef,
} = useContext(GridContext);
const { updatedDep, updatingCols } = useContext(GridUpdatingContext);
const gridContext = useContext(GridContext);
const { checkUpdating, updatedDep, updatingCols } = useContext(GridUpdatingContext);
const { prePopupOps } = useContext(GridContext);

const gridDivRef = useRef<HTMLDivElement>(null);

Expand Down Expand Up @@ -387,13 +387,23 @@ export const Grid = ({
*/
const startCellEditing = useCallback(
(event: CellEvent) => {
event.data.id &&
gridContext.startCellEditing({
rowId: event.data.id,
colId: event.column.getColId(),
prePopupOps();
if (!event.node.isSelected()) {
event.node.setSelected(true, true);
}
// Cell already being edited, so don't re-edit until finished
if (checkUpdating([event.colDef.field ?? ""], event.data.id)) {
return;
}

if (event.rowIndex !== null) {
event.api.startEditingCell({
rowIndex: event.rowIndex,
colKey: event.column.getColId(),
});
}
},
[gridContext],
[checkUpdating, prePopupOps],
);

/**
Expand Down

0 comments on commit c8a6509

Please sign in to comment.