fix(virtual_table): Commit pending changes on tab_out
When user tabs out of the table with pending changes in RowEditBuffer, commit them before exiting. Prevents data loss when leaving ghost row.
This commit is contained in:
parent
ef30cc7d1b
commit
51705f8fc7
1 changed files with 20 additions and 1 deletions
|
|
@ -1139,11 +1139,30 @@ fn handleKeyboard(
|
|||
}
|
||||
|
||||
// =========================================================================
|
||||
// Tab navigation
|
||||
// Tab navigation (con commit de cambios pendientes)
|
||||
// =========================================================================
|
||||
if (events.tab_out) {
|
||||
// Solo si CellEditor no procesó Tab (evita doble procesamiento)
|
||||
if (result.navigate_direction == .none) {
|
||||
// IMPORTANTE: Commit cambios pendientes antes de salir de la tabla
|
||||
if (list_state.row_edit_buffer.has_changes) {
|
||||
const current_row_id = list_state.row_edit_buffer.row_id;
|
||||
const is_ghost = table_core.isGhostRow(current_row_id);
|
||||
|
||||
// Forzar commit de la fila actual (pasamos NEW_ROW_ID para forzar diferencia)
|
||||
if (table_core.checkRowChangeAndCommit(
|
||||
&list_state.row_edit_buffer,
|
||||
table_core.NEW_ROW_ID - 1, // ID diferente para forzar commit
|
||||
0,
|
||||
false,
|
||||
&result.row_changes,
|
||||
)) |commit_info| {
|
||||
result.row_committed = true;
|
||||
result.row_commit_id = current_row_id;
|
||||
result.row_commit_is_insert = is_ghost;
|
||||
result.row_changes_count = commit_info.change_count;
|
||||
}
|
||||
}
|
||||
result.tab_out = true;
|
||||
result.tab_shift = events.tab_shift;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue