fix(fe): KsDataGrid - prevent duplicate edit mode on cell focus
Improved onCellFocused to check if already editing same cell before starting edit mode. Problem: Enter key moves to next cell + startEditingCell(), then onCellFocused fires and tries to startEditingCell() again on same cell, causing timing issues. Solution: Check getEditingCell() to see if we're already editing the focused cell - If same cell: skip (already editing) - If different cell: enter edit mode Result: Enter key → next cell → auto edit mode (no duplication) Tab/Click/Arrow → auto edit mode (only once) Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -117,12 +117,19 @@ function onCellFocused(event: CellFocusedEvent): void {
|
|||||||
if (event.column && event.rowIndex !== undefined) {
|
if (event.column && event.rowIndex !== undefined) {
|
||||||
const colDef = event.column.getColDef()
|
const colDef = event.column.getColDef()
|
||||||
if (colDef.editable) {
|
if (colDef.editable) {
|
||||||
setTimeout(() => {
|
const currentEditingCell = event.api.getEditingCell()
|
||||||
|
const focusedColId = event.column.getColId()
|
||||||
|
|
||||||
|
const isSameCell = currentEditingCell &&
|
||||||
|
currentEditingCell.rowIndex === event.rowIndex &&
|
||||||
|
currentEditingCell.column?.getColId() === focusedColId
|
||||||
|
|
||||||
|
if (!isSameCell) {
|
||||||
event.api.startEditingCell({
|
event.api.startEditingCell({
|
||||||
rowIndex: event.rowIndex,
|
rowIndex: event.rowIndex,
|
||||||
colKey: event.column!.getColId()
|
colKey: focusedColId
|
||||||
})
|
})
|
||||||
}, 50)
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user