refactor: KsDataGrid - simplify focusRow and rely on AG Grid native Enter navigation

This commit is contained in:
2026-08-16 21:04:41 +09:00
parent 823312fd26
commit 8aad550c77
@@ -112,7 +112,6 @@ function onCellValueChanged(event: CellValueChangedEvent): void {
} }
} }
function onSortChanged(params: { api: { redrawRows: () => void; refreshCells: (options: { force: boolean }) => void } }): void { function onSortChanged(params: { api: { redrawRows: () => void; refreshCells: (options: { force: boolean }) => void } }): void {
params.api.redrawRows() params.api.redrawRows()
} }
@@ -139,15 +138,10 @@ function onGridReady(params: GridReadyEvent): void {
params.api.sizeColumnsToFit() params.api.sizeColumnsToFit()
} }
function focusRow(rowIndex: number, colKey?: string): void { function focusRow(rowIndex: number, colKey?: string): void {
if (!gridApi.value) return if (!gridApi.value) return
const col = colKey || (props.columns[0]?.field ?? '') const col = colKey || (props.columns[0]?.field ?? '')
const attempt = () => {
if (!gridApi.value) return
gridApi.value.ensureIndexVisible(rowIndex) gridApi.value.ensureIndexVisible(rowIndex)
if (col) { if (col) {
gridApi.value.setFocusedCell(rowIndex, col) gridApi.value.setFocusedCell(rowIndex, col)
@@ -155,11 +149,6 @@ function focusRow(rowIndex: number, colKey?: string): void {
} }
} }
attempt()
setTimeout(attempt, 50)
setTimeout(attempt, 150)
}
function redrawRows(): void { function redrawRows(): void {
gridApi.value?.redrawRows() gridApi.value?.redrawRows()
} }