fix(table_core): Show pending values from RowEditBuffer in render

Fix Tab showing empty cell after editing:
- Add edit_buffer field to DrawRowsConfig
- drawRowsWithDataSource now checks RowEditBuffer before DataSource
- VirtualAdvancedTable passes row_edit_buffer to render

Priority: RowEditBuffer (user typed) > DataSource (DB/memory)
This commit is contained in:
reugenio 2025-12-27 23:00:02 +01:00
parent 9c9c53afea
commit ef30cc7d1b
2 changed files with 18 additions and 1 deletions

View file

@ -565,6 +565,9 @@ pub const DrawRowsConfig = struct {
/// ID de fila con cambios pendientes (dirty tracking visual) /// ID de fila con cambios pendientes (dirty tracking visual)
/// Si no es null y coincide con el row_id actual, se aplica blend naranja /// Si no es null y coincide con el row_id actual, se aplica blend naranja
dirty_row_id: ?i64 = null, dirty_row_id: ?i64 = null,
/// Buffer de edición de fila para priorizar valores pendientes en renderizado
/// Permite mostrar lo que el usuario ha tecleado antes de que se guarde en BD
edit_buffer: ?*const RowEditBuffer = null,
}; };
/// Dibuja las filas de una tabla usando TableDataSource. /// Dibuja las filas de una tabla usando TableDataSource.
@ -675,7 +678,20 @@ pub fn drawRowsWithDataSource(
} }
// Obtener texto de la celda // Obtener texto de la celda
const cell_text = datasource.getCellValueInto(row_idx, col_idx, cell_buffer); // PRIORIDAD 1: Valor pendiente en RowEditBuffer (lo que el usuario tecleó)
// PRIORIDAD 2: Valor del DataSource (BD o memoria)
var cell_text: []const u8 = "";
const row_id = datasource.getRowId(row_idx);
if (config.edit_buffer) |eb| {
if (eb.row_id == row_id) {
if (eb.getPendingValue(col_idx)) |pending| {
cell_text = pending;
}
}
}
if (cell_text.len == 0) {
cell_text = datasource.getCellValueInto(row_idx, col_idx, cell_buffer);
}
// Copiar a frame allocator para persistencia durante render // Copiar a frame allocator para persistencia durante render
const text_to_draw = ctx.frameAllocator().dupe(u8, cell_text) catch cell_text; const text_to_draw = ctx.frameAllocator().dupe(u8, cell_text) catch cell_text;

View file

@ -884,6 +884,7 @@ fn drawRows(
.colors = render_colors, .colors = render_colors,
.columns = render_cols[0..num_cols], .columns = render_cols[0..num_cols],
.dirty_row_id = dirty_id, .dirty_row_id = dirty_id,
.edit_buffer = &list_state.row_edit_buffer,
}, },
&cell_buffer, &cell_buffer,
); );