From ca187e743e2f305cd487df12d20d6da12b8bb798 Mon Sep 17 00:00:00 2001 From: reugenio Date: Sun, 28 Dec 2025 02:28:55 +0100 Subject: [PATCH] feat(virtual_table): Auto-reload when injected row leaves viewport When an injected row has been committed (injected_committed=true) and scrolling moves it out of the visible area: - Sets needs_reload=true in result - Clears injection state This triggers the panel to refetch data from DB, where the new row will appear in its proper sorted position. --- .../virtual_advanced_table.zig | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/widgets/virtual_advanced_table/virtual_advanced_table.zig b/src/widgets/virtual_advanced_table/virtual_advanced_table.zig index 35aeb13..677ccfe 100644 --- a/src/widgets/virtual_advanced_table/virtual_advanced_table.zig +++ b/src/widgets/virtual_advanced_table/virtual_advanced_table.zig @@ -571,6 +571,18 @@ pub fn virtualAdvancedTableRect( } } + // ========================================================================= + // Detectar si la fila inyectada salió del viewport (requiere reload) + // ========================================================================= + if (list_state.hasInjection()) { + // Solo hacer reload si la fila ya fue guardada (injected_committed) + // y ya no es visible en el viewport actual + if (list_state.injected_committed and !list_state.isInjectionVisible(visible_rows)) { + result.needs_reload = true; + list_state.clearInjection(); + } + } + // ========================================================================= // Tips Proactivos (FASE I): Rotar tips cada ~10 segundos // =========================================================================