fix(fe): KsDataGrid - Enter key uses Tab navigation (suggestedNextCell)
Simplified navigateToNextCell to let Enter key use default AG Grid Tab behavior. Previous: Custom Enter navigation (next editable column only) New: Return suggestedNextCell for Enter, which is Tab's default behavior This makes Enter and Tab fully equivalent, consistent with user expectation. Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -190,34 +190,10 @@ import type { NavigateToNextCellParams, CellPosition } from 'ag-grid-community'
|
|||||||
|
|
||||||
|
|
||||||
function navigateToNextCell(params: NavigateToNextCellParams): CellPosition | null {
|
function navigateToNextCell(params: NavigateToNextCellParams): CellPosition | null {
|
||||||
const previousCell = params.previousCellPosition
|
|
||||||
const suggestedNextCell = params.nextCellPosition
|
const suggestedNextCell = params.nextCellPosition
|
||||||
|
|
||||||
if (params.key === 'Enter' || String(params.key) === '13') {
|
if (params.key === 'Enter' || String(params.key) === '13') {
|
||||||
const allColumns = params.api.getAllGridColumns()
|
return suggestedNextCell
|
||||||
const editableCols = allColumns.filter(c => {
|
|
||||||
const colDef = c.getColDef()
|
|
||||||
return colDef.editable === true || typeof colDef.editable === 'function'
|
|
||||||
})
|
|
||||||
|
|
||||||
if (editableCols.length > 0) {
|
|
||||||
const currentColId = previousCell.column.getColId()
|
|
||||||
const currentIndex = editableCols.findIndex(c => c.getColId() === currentColId)
|
|
||||||
|
|
||||||
if (currentIndex >= 0 && currentIndex < editableCols.length - 1) {
|
|
||||||
const nextCol = editableCols[currentIndex + 1]
|
|
||||||
const colId = nextCol.getColId()
|
|
||||||
setTimeout(() => {
|
|
||||||
params.api.startEditingCell({ rowIndex: previousCell.rowIndex, colKey: colId })
|
|
||||||
}, 30)
|
|
||||||
return {
|
|
||||||
rowIndex: previousCell.rowIndex,
|
|
||||||
column: nextCol,
|
|
||||||
rowPinned: previousCell.rowPinned
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return suggestedNextCell
|
return suggestedNextCell
|
||||||
|
|||||||
Reference in New Issue
Block a user