From 5ecc54f01526117ee020533c8cc0d31972ff7af8 Mon Sep 17 00:00:00 2001 From: sedax90 <5001801+sedax90@users.noreply.github.com> Date: Sun, 8 Nov 2026 12:14:27 +0100 Subject: [PATCH 01/11] feat(linux-grid): mark a field's key, edit and type in the row details --- .../app/src/ui/data_grid/row_detail/fields.rs | 77 +++++++++++++++---- .../app/src/ui/data_grid/row_detail/tests.rs | 28 +++++++ linux/crates/app/src/ui/icons.rs | 2 + linux/data/resources/style.css | 9 +++ 4 files changed, 99 insertions(+), 17 deletions(-) diff --git a/linux/crates/app/src/ui/data_grid/row_detail/fields.rs b/linux/crates/app/src/ui/data_grid/row_detail/fields.rs index b698999b09..0e076261f2 100644 --- a/linux/crates/app/src/ui/data_grid/row_detail/fields.rs +++ b/linux/crates/app/src/ui/data_grid/row_detail/fields.rs @@ -11,6 +11,7 @@ use crate::services::grid::{GridColumn, auto_filled_sentinel, display_text}; use crate::ui::data_grid::tracked_values::cell_description; use crate::ui::data_grid::{DataGrid, GridRow, ServerValue, TrackedValues}; use crate::ui::handler_guard::HandlerGuard; +use crate::ui::icons; /// The data columns in the order the fields list shows them: the ones on /// screen as the grid shows them, then the hidden ones. @@ -63,20 +64,38 @@ pub fn field_value(tracked: &TrackedValues, row: &GridRow, column: &GridColumn) } /// A field's row: its name and type on one line, its value on the next. +/// One field: its name with a key for a primary key column, a pencil +/// while it holds an edit and the type as a badge, over its value. fn field_row() -> gtk::Box { + let key = gtk::Image::builder() + .icon_name(icons::DIALOG_PASSWORD) + .pixel_size(12) + .visible(false) + .build(); + key.add_css_class("warning"); + key.set_accessible_role(gtk::AccessibleRole::Presentation); let name = gtk::Label::builder() .xalign(0.0) .hexpand(true) - .ellipsize(pango::EllipsizeMode::End) + .ellipsize(pango::EllipsizeMode::Middle) .build(); + name.add_css_class("dimmed"); + let edited = gtk::Image::builder() + .icon_name(icons::DOCUMENT_EDIT) + .pixel_size(12) + .visible(false) + .build(); + edited.add_css_class("accent"); + edited.set_accessible_role(gtk::AccessibleRole::Presentation); let kind = gtk::Label::builder() - .xalign(1.0) + .xalign(0.5) .ellipsize(pango::EllipsizeMode::End) .build(); - kind.add_css_class("caption"); - kind.add_css_class("dimmed"); + kind.add_css_class("field-type"); let top = gtk::Box::new(gtk::Orientation::Horizontal, 6); + top.append(&key); top.append(&name); + top.append(&edited); top.append(&kind); let value = gtk::Inscription::builder() .hexpand(true) @@ -85,9 +104,9 @@ fn field_row() -> gtk::Box { .build(); let row = gtk::Box::builder() .orientation(gtk::Orientation::Vertical) - .spacing(2) - .margin_top(6) - .margin_bottom(6) + .spacing(3) + .margin_top(7) + .margin_bottom(7) .margin_start(12) .margin_end(12) .build(); @@ -96,6 +115,30 @@ fn field_row() -> gtk::Box { row } +/// The widgets of a field row, in the order `field_row` makes them. +struct FieldParts { + key: gtk::Image, + name: gtk::Label, + edited: gtk::Image, + kind: gtk::Label, + value: gtk::Inscription, +} + +fn field_parts(row: >k::Widget) -> Option { + let top = row.first_child()?; + let key = top.first_child()?; + let name = key.next_sibling()?; + let edited = name.next_sibling()?; + let kind = edited.next_sibling()?; + Some(FieldParts { + key: key.downcast().ok()?, + name: name.downcast().ok()?, + edited: edited.downcast().ok()?, + kind: kind.downcast().ok()?, + value: row.last_child()?.downcast().ok()?, + }) +} + fn set_class(widget: &impl IsA, class: &str, on: bool) { match on { true => widget.as_ref().add_css_class(class), @@ -192,18 +235,17 @@ impl RowDetailPane { let Some(row_box) = item.child() else { return; }; - let top = row_box.first_child(); - let (Some(name), Some(kind), Some(shown)) = ( - top.as_ref() - .and_then(|top| top.first_child()) - .and_downcast::(), - top.as_ref() - .and_then(|top| top.last_child()) - .and_downcast::(), - row_box.last_child().and_downcast::(), - ) else { + let Some(FieldParts { + key, + name, + edited, + kind, + value: shown, + }) = field_parts(&row_box) + else { return; }; + key.set_visible(column.catalog.as_ref().is_some_and(|catalog| catalog.primary_key)); name.set_label(&column.name); kind.set_label(&column.value_type().name); item.set_accessible_label(&column.name); @@ -212,6 +254,7 @@ impl RowDetailPane { return; }; let value = field_value(&grid.tracked(), &row, &column); + edited.set_visible(value.modified); shown.set_text(Some(&value.text)); shown.set_attributes(Some(&value_attributes(&value))); set_class(&shown, "dimmed", value.placeholder || value.deleted); diff --git a/linux/crates/app/src/ui/data_grid/row_detail/tests.rs b/linux/crates/app/src/ui/data_grid/row_detail/tests.rs index 831c4f96df..116a5b5936 100644 --- a/linux/crates/app/src/ui/data_grid/row_detail/tests.rs +++ b/linux/crates/app/src/ui/data_grid/row_detail/tests.rs @@ -1424,3 +1424,31 @@ fn a_page_that_takes_the_row_closes_its_clock_and_writes_nothing() { ); assert!(!pane.imp().clock_popover.is_visible()); } + +/// A primary key column's field carries a key, and a field holding an +/// edit a pencil, so each reads without opening the field. +#[gtk4::test] +fn the_fields_mark_the_primary_key_and_a_pending_edit() { + let (grid, pane) = opened(two_text_columns(), two_text_values()); + grid.focus(0, 1); + let marked = |icon: &str| { + descendants(&pane.imp().field_list.get()) + .into_iter() + .filter_map(|widget| widget.downcast::().ok()) + .filter(|image| image.is_visible() && image.icon_name().as_deref() == Some(icon)) + .count() + }; + assert_eq!(marked(crate::ui::icons::DIALOG_PASSWORD), 1, "the id column is the key"); + assert_eq!(marked(crate::ui::icons::DOCUMENT_EDIT), 0); + + let delta = grid.tracker.apply(TrackerEdit::Cell { + row_key: key(1), + col: 1, + original: Value::Text("A".into()), + value: CellInput::Value(Value::Text("changed".into())), + }); + grid.grid.apply_delta(&delta); + drain_main_context(); + + assert_eq!(marked(crate::ui::icons::DOCUMENT_EDIT), 1); +} diff --git a/linux/crates/app/src/ui/icons.rs b/linux/crates/app/src/ui/icons.rs index aa2c179ddf..81aba06ea3 100644 --- a/linux/crates/app/src/ui/icons.rs +++ b/linux/crates/app/src/ui/icons.rs @@ -9,6 +9,8 @@ pub const APPLICATIONS_SCIENCE: &str = "applications-science-symbolic"; pub const ASSISTANT: &str = "assistant-symbolic"; pub const CHANGES_PREVENT: &str = "changes-prevent-symbolic"; pub const COMPUTER: &str = "computer-symbolic"; +/// A key, for a primary key column. +pub const DIALOG_PASSWORD: &str = "dialog-password-symbolic"; pub const DIALOG_ERROR: &str = "dialog-error-symbolic"; pub const DIALOG_WARNING: &str = "dialog-warning-symbolic"; pub const DOCUMENT_EDIT: &str = "document-edit-symbolic"; diff --git a/linux/data/resources/style.css b/linux/data/resources/style.css index 4c92a7f3e9..37eab09f2f 100644 --- a/linux/data/resources/style.css +++ b/linux/data/resources/style.css @@ -219,3 +219,12 @@ tp-diagram-canvas > .tp-diagram-border { tp-diagram-canvas > .tp-diagram-accent { color: var(--accent-color); } + +/* A field's type in the row details, as a badge beside its name. */ +.field-type { + font-size: smaller; + padding: 1px 6px; + border-radius: 6px; + background-color: color-mix(in srgb, currentColor 10%, transparent); + opacity: 0.8; +} From d0f125b1beca3ac95cbc16ca6cdefa4a3e99428d Mon Sep 17 00:00:00 2001 From: sedax90 <5001801+sedax90@users.noreply.github.com> Date: Sun, 8 Nov 2026 12:16:43 +0100 Subject: [PATCH 02/11] docs(linux-grid): add the changelog entry --- linux/changelog.d/4112.added.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 linux/changelog.d/4112.added.md diff --git a/linux/changelog.d/4112.added.md b/linux/changelog.d/4112.added.md new file mode 100644 index 0000000000..25afe55cce --- /dev/null +++ b/linux/changelog.d/4112.added.md @@ -0,0 +1 @@ +A field in the row details names its type in a badge and marks a primary key and a pending edit. From bb9fc32819efedefc08b1416edf3f4b093bd9533 Mon Sep 17 00:00:00 2001 From: sedax90 <5001801+sedax90@users.noreply.github.com> Date: Sun, 8 Nov 2026 12:18:58 +0100 Subject: [PATCH 03/11] feat(linux-grid): search the row details' fields and show the edited ones only --- .../app/src/ui/data_grid/row_detail/fields.rs | 55 ++++++++++++++++++- .../app/src/ui/data_grid/row_detail/imp.rs | 7 +++ .../app/src/ui/data_grid/row_detail/tests.rs | 31 +++++++++++ linux/data/resources/ui/row-detail-pane.ui | 52 +++++++++++++++--- 4 files changed, 133 insertions(+), 12 deletions(-) diff --git a/linux/crates/app/src/ui/data_grid/row_detail/fields.rs b/linux/crates/app/src/ui/data_grid/row_detail/fields.rs index b698999b09..4b09a9d0d1 100644 --- a/linux/crates/app/src/ui/data_grid/row_detail/fields.rs +++ b/linux/crates/app/src/ui/data_grid/row_detail/fields.rs @@ -124,7 +124,26 @@ impl RowDetailPane { let imp = self.imp(); imp.selection.set_autoselect(false); imp.selection.set_can_unselect(true); - imp.selection.set_model(Some(&imp.fields.0)); + imp.filtered.set_model(Some(&imp.fields.0)); + imp.filtered.set_filter(Some(&imp.field_filter)); + imp.selection.set_model(Some(&imp.filtered)); + imp.field_filter.set_filter_func(glib::clone!( + #[weak(rename_to = pane)] + self, + #[upgrade_or] + true, + move |item| pane.field_shown(field_of(Some(item.clone()))) + )); + imp.field_search.connect_search_changed(glib::clone!( + #[weak(rename_to = pane)] + self, + move |_| pane.refilter_fields() + )); + imp.edited_toggle.connect_toggled(glib::clone!( + #[weak(rename_to = pane)] + self, + move |_| pane.refilter_fields() + )); imp.field_list.set_model(Some(&imp.selection)); imp.field_list.set_factory(Some(&self.field_factory())); imp.selection.connect_selected_notify(glib::clone!( @@ -180,6 +199,35 @@ impl RowDetailPane { for item in &bound { self.draw_field(item); } + // An edit made or undone changes which fields are edited. + if self.imp().edited_toggle.is_active() { + self.refilter_fields(); + } + } + + fn refilter_fields(&self) { + self.imp().field_filter.changed(gtk::FilterChange::Different); + } + + /// Whether the search and the edited-only toggle leave `column`'s + /// field in the list. + fn field_shown(&self, column: Option) -> bool { + let imp = self.imp(); + let (Some(grid), Some(column)) = (self.grid(), column) else { + return true; + }; + let Some(column) = grid.grid_columns().get(column).cloned() else { + return true; + }; + let wanted = imp.field_search.text().to_lowercase(); + if !wanted.is_empty() && !column.name.to_lowercase().contains(&wanted) { + return false; + } + if !imp.edited_toggle.is_active() { + return true; + } + self.current_row() + .is_some_and(|row| field_value(&grid.tracked(), &row, &column).modified) } fn draw_field(&self, item: >k::ListItem) { @@ -262,9 +310,10 @@ impl RowDetailPane { pub(super) fn select_in_list(&self, column: Option) { let imp = self.imp(); - let store = &imp.fields.0; + // The list as shown, which the search may have narrowed. + let shown = &imp.selection; let position = column - .and_then(|column| (0..store.n_items()).find(|position| field_of(store.item(*position)) == Some(column))) + .and_then(|column| (0..shown.n_items()).find(|position| field_of(shown.item(*position)) == Some(column))) .unwrap_or(gtk::INVALID_LIST_POSITION); if imp.selection.selected() == position { return; diff --git a/linux/crates/app/src/ui/data_grid/row_detail/imp.rs b/linux/crates/app/src/ui/data_grid/row_detail/imp.rs index d71dbbd2e0..39ea89ac9e 100644 --- a/linux/crates/app/src/ui/data_grid/row_detail/imp.rs +++ b/linux/crates/app/src/ui/data_grid/row_detail/imp.rs @@ -41,6 +41,10 @@ pub struct RowDetailPane { #[template_child] pub field_list: TemplateChild, #[template_child] + pub field_search: TemplateChild, + #[template_child] + pub edited_toggle: TemplateChild, + #[template_child] pub field_label: TemplateChild, #[template_child] pub choice_button: TemplateChild, @@ -80,6 +84,9 @@ pub struct RowDetailPane { pub grid: glib::WeakRef, pub fields: Fields, pub selection: gtk::SingleSelection, + /// The fields the search and the edited-only toggle leave in the list. + pub filtered: gtk::FilterListModel, + pub field_filter: gtk::CustomFilter, /// The row the pane shows, while it has one. pub shown: RefCell>, /// The data column of the selected field. diff --git a/linux/crates/app/src/ui/data_grid/row_detail/tests.rs b/linux/crates/app/src/ui/data_grid/row_detail/tests.rs index 831c4f96df..4a4dc634d4 100644 --- a/linux/crates/app/src/ui/data_grid/row_detail/tests.rs +++ b/linux/crates/app/src/ui/data_grid/row_detail/tests.rs @@ -1424,3 +1424,34 @@ fn a_page_that_takes_the_row_closes_its_clock_and_writes_nothing() { ); assert!(!pane.imp().clock_popover.is_visible()); } + +/// The search narrows the fields to the names it matches, and the toggle +/// to the ones holding an edit. +#[gtk4::test] +fn the_field_search_and_the_edited_toggle_narrow_the_list() { + let (grid, pane) = opened(two_text_columns(), two_text_values()); + grid.focus(0, 1); + let imp = pane.imp(); + let listed = || imp.selection.n_items(); + assert_eq!(listed(), 2); + + // The entry reports a search after its own short delay. + imp.field_search.set_text("NAM"); + wait_until(WAIT, || listed() == 1).expect("a search matches a name in any case"); + + imp.field_search.set_text(""); + wait_until(WAIT, || listed() == 2).expect("the fields come back"); + imp.edited_toggle.set_active(true); + drain_main_context(); + assert_eq!(listed(), 0, "nothing is edited yet"); + + let delta = grid.tracker.apply(TrackerEdit::Cell { + row_key: key(1), + col: 1, + original: Value::Text("A".into()), + value: CellInput::Value(Value::Text("changed".into())), + }); + grid.grid.apply_delta(&delta); + drain_main_context(); + assert_eq!(listed(), 1, "the edited field joins the list"); +} diff --git a/linux/data/resources/ui/row-detail-pane.ui b/linux/data/resources/ui/row-detail-pane.ui index a0465b692c..d8870c5d12 100644 --- a/linux/data/resources/ui/row-detail-pane.ui +++ b/linux/data/resources/ui/row-detail-pane.ui @@ -128,16 +128,50 @@ false false - - never - 120 - - - - Fields - + + vertical + + + + 6 + 6 + 6 + 12 + 12 + + + true + Search fields + + Search fields + + + + + + document-edit-symbolic + Show edited fields only + + Show edited fields only + + + - + + + + true + never + 120 + + + + Fields + + + + + From 69e32e52feaba9af6037debcd1517533e7473aca Mon Sep 17 00:00:00 2001 From: sedax90 <5001801+sedax90@users.noreply.github.com> Date: Sun, 8 Nov 2026 12:20:40 +0100 Subject: [PATCH 04/11] docs(linux-grid): add the changelog entry --- linux/changelog.d/4113.added.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 linux/changelog.d/4113.added.md diff --git a/linux/changelog.d/4113.added.md b/linux/changelog.d/4113.added.md new file mode 100644 index 0000000000..67cebaf25c --- /dev/null +++ b/linux/changelog.d/4113.added.md @@ -0,0 +1 @@ +The row details search their fields by name and can show only the edited ones. From f743a96db2fe4cfab77c8b6ca28299fe3304d3d6 Mon Sep 17 00:00:00 2001 From: Ngo Quoc Dat Date: Sun, 8 Nov 2026 19:38:18 +0700 Subject: [PATCH 05/11] fix(linux-grid): name a field's key and type to screen readers and drop the badge style --- linux/changelog.d/4112.added.md | 2 +- .../app/src/ui/data_grid/row_detail/fields.rs | 63 ++++++++++-------- .../app/src/ui/data_grid/row_detail/tests.rs | 64 +++++++++++++++---- linux/crates/app/src/ui/icons.rs | 5 +- linux/data/resources/style.css | 9 --- 5 files changed, 92 insertions(+), 51 deletions(-) diff --git a/linux/changelog.d/4112.added.md b/linux/changelog.d/4112.added.md index 25afe55cce..95b486e939 100644 --- a/linux/changelog.d/4112.added.md +++ b/linux/changelog.d/4112.added.md @@ -1 +1 @@ -A field in the row details names its type in a badge and marks a primary key and a pending edit. +Row Details marks a primary key field with a key, and a field holding an unsaved edit with a pencil. diff --git a/linux/crates/app/src/ui/data_grid/row_detail/fields.rs b/linux/crates/app/src/ui/data_grid/row_detail/fields.rs index 0e076261f2..fc38047a6c 100644 --- a/linux/crates/app/src/ui/data_grid/row_detail/fields.rs +++ b/linux/crates/app/src/ui/data_grid/row_detail/fields.rs @@ -6,6 +6,7 @@ use gtk4::{self as gtk, glib, pango}; use tablepro_core::Value; use super::RowDetailPane; +use crate::i18n::gettext; use crate::services::change_tracker::CellState; use crate::services::grid::{GridColumn, auto_filled_sentinel, display_text}; use crate::ui::data_grid::tracked_values::cell_description; @@ -63,35 +64,47 @@ pub fn field_value(tracked: &TrackedValues, row: &GridRow, column: &GridColumn) } } -/// A field's row: its name and type on one line, its value on the next. -/// One field: its name with a key for a primary key column, a pencil -/// while it holds an edit and the type as a badge, over its value. +fn is_primary_key(column: &GridColumn) -> bool { + column.catalog.as_ref().is_some_and(|catalog| catalog.primary_key) +} + +// The key has no role of its own, so the label is where a screen reader hears it. +pub(super) fn field_label(column: &GridColumn) -> String { + let mut parts = vec![column.name.clone()]; + let type_name = &column.value_type().name; + if !type_name.is_empty() { + parts.push(type_name.clone()); + } + if is_primary_key(column) { + parts.push(gettext("primary key")); + } + parts.join(", ") +} + +fn marker(icon: &str) -> gtk::Image { + let image = gtk::Image::builder().icon_name(icon).visible(false).build(); + image.set_accessible_role(gtk::AccessibleRole::Presentation); + image +} + fn field_row() -> gtk::Box { - let key = gtk::Image::builder() - .icon_name(icons::DIALOG_PASSWORD) - .pixel_size(12) - .visible(false) - .build(); - key.add_css_class("warning"); - key.set_accessible_role(gtk::AccessibleRole::Presentation); + let key = marker(icons::PRIMARY_KEY); + // Dimmed as a libadwaita property row's title, so the eye lands on the value. let name = gtk::Label::builder() .xalign(0.0) .hexpand(true) .ellipsize(pango::EllipsizeMode::Middle) .build(); name.add_css_class("dimmed"); - let edited = gtk::Image::builder() - .icon_name(icons::DOCUMENT_EDIT) - .pixel_size(12) - .visible(false) - .build(); - edited.add_css_class("accent"); - edited.set_accessible_role(gtk::AccessibleRole::Presentation); + let edited = marker(icons::DOCUMENT_EDIT); + // The colour the grid and the value below give a pending value. + edited.add_css_class("warning"); let kind = gtk::Label::builder() - .xalign(0.5) + .xalign(1.0) .ellipsize(pango::EllipsizeMode::End) .build(); - kind.add_css_class("field-type"); + kind.add_css_class("caption"); + kind.add_css_class("dimmed"); let top = gtk::Box::new(gtk::Orientation::Horizontal, 6); top.append(&key); top.append(&name); @@ -104,9 +117,9 @@ fn field_row() -> gtk::Box { .build(); let row = gtk::Box::builder() .orientation(gtk::Orientation::Vertical) - .spacing(3) - .margin_top(7) - .margin_bottom(7) + .spacing(2) + .margin_top(6) + .margin_bottom(6) .margin_start(12) .margin_end(12) .build(); @@ -115,7 +128,6 @@ fn field_row() -> gtk::Box { row } -/// The widgets of a field row, in the order `field_row` makes them. struct FieldParts { key: gtk::Image, name: gtk::Label, @@ -245,11 +257,12 @@ impl RowDetailPane { else { return; }; - key.set_visible(column.catalog.as_ref().is_some_and(|catalog| catalog.primary_key)); + key.set_visible(is_primary_key(&column)); name.set_label(&column.name); kind.set_label(&column.value_type().name); - item.set_accessible_label(&column.name); + item.set_accessible_label(&field_label(&column)); let Some(row) = self.current_row() else { + edited.set_visible(false); shown.set_text(None); return; }; diff --git a/linux/crates/app/src/ui/data_grid/row_detail/tests.rs b/linux/crates/app/src/ui/data_grid/row_detail/tests.rs index 116a5b5936..8d0a213f14 100644 --- a/linux/crates/app/src/ui/data_grid/row_detail/tests.rs +++ b/linux/crates/app/src/ui/data_grid/row_detail/tests.rs @@ -14,7 +14,7 @@ use tablepro_core::{ColumnInfo, Value}; use super::RowDetailPane; use super::calendar::{day_of, day_start_offset, with_day}; use super::clock::{ClockField, time_of, with_time}; -use super::fields::field_order; +use super::fields::{field_label, field_order}; use super::value_editor::value_content; use crate::services::change_tracker::RowKey; use crate::services::grid::{CellLock, GridColumn, GridRowId, grid_columns}; @@ -1425,21 +1425,38 @@ fn a_page_that_takes_the_row_closes_its_clock_and_writes_nothing() { assert!(!pane.imp().clock_popover.is_visible()); } -/// A primary key column's field carries a key, and a field holding an -/// edit a pencil, so each reads without opening the field. +fn drawn_field(pane: &RowDetailPane, column: usize) -> gtk::ListItem { + pane.imp() + .bound + .borrow() + .iter() + .find(|item| { + item.item() + .and_downcast::() + .is_some_and(|boxed| *boxed.borrow::() == column) + }) + .cloned() + .expect("the field is drawn") +} + +fn marks(pane: &RowDetailPane, column: usize, icon: &str) -> bool { + let row = drawn_field(pane, column).child().expect("the field's row"); + descendants(&row) + .into_iter() + .filter_map(|widget| widget.downcast::().ok()) + .any(|image| image.is_visible() && image.icon_name().as_deref() == Some(icon)) +} + #[gtk4::test] -fn the_fields_mark_the_primary_key_and_a_pending_edit() { +fn a_field_marks_its_primary_key_and_a_pending_edit() { let (grid, pane) = opened(two_text_columns(), two_text_values()); grid.focus(0, 1); - let marked = |icon: &str| { - descendants(&pane.imp().field_list.get()) - .into_iter() - .filter_map(|widget| widget.downcast::().ok()) - .filter(|image| image.is_visible() && image.icon_name().as_deref() == Some(icon)) - .count() - }; - assert_eq!(marked(crate::ui::icons::DIALOG_PASSWORD), 1, "the id column is the key"); - assert_eq!(marked(crate::ui::icons::DOCUMENT_EDIT), 0); + drain_main_context(); + let key_mark = crate::ui::icons::PRIMARY_KEY; + let edit_mark = crate::ui::icons::DOCUMENT_EDIT; + assert!(marks(&pane, 0, key_mark)); + assert!(!marks(&pane, 1, key_mark)); + assert!(!marks(&pane, 1, edit_mark)); let delta = grid.tracker.apply(TrackerEdit::Cell { row_key: key(1), @@ -1449,6 +1466,25 @@ fn the_fields_mark_the_primary_key_and_a_pending_edit() { }); grid.grid.apply_delta(&delta); drain_main_context(); + assert!(marks(&pane, 1, edit_mark)); + assert!(!marks(&pane, 0, edit_mark)); + + grid.grid.undo(); + drain_main_context(); + assert!(!marks(&pane, 1, edit_mark), "the pencil outlived the undo"); +} + +#[gtk4::test] +fn a_field_names_its_type_and_its_key_to_a_screen_reader() { + let (grid, pane) = opened(two_text_columns(), two_text_values()); + grid.focus(0, 1); + drain_main_context(); - assert_eq!(marked(crate::ui::icons::DOCUMENT_EDIT), 1); + assert_eq!(drawn_field(&pane, 0).accessible_label().as_deref(), Some("id, integer, primary key")); + assert_eq!(drawn_field(&pane, 1).accessible_label().as_deref(), Some("name, text")); + let result_column = GridColumn { + catalog: None, + ..column_of(named("id", "integer", true)) + }; + assert_eq!(field_label(&result_column), "id, integer"); } diff --git a/linux/crates/app/src/ui/icons.rs b/linux/crates/app/src/ui/icons.rs index 81aba06ea3..d27cdb630c 100644 --- a/linux/crates/app/src/ui/icons.rs +++ b/linux/crates/app/src/ui/icons.rs @@ -9,8 +9,6 @@ pub const APPLICATIONS_SCIENCE: &str = "applications-science-symbolic"; pub const ASSISTANT: &str = "assistant-symbolic"; pub const CHANGES_PREVENT: &str = "changes-prevent-symbolic"; pub const COMPUTER: &str = "computer-symbolic"; -/// A key, for a primary key column. -pub const DIALOG_PASSWORD: &str = "dialog-password-symbolic"; pub const DIALOG_ERROR: &str = "dialog-error-symbolic"; pub const DIALOG_WARNING: &str = "dialog-warning-symbolic"; pub const DOCUMENT_EDIT: &str = "document-edit-symbolic"; @@ -42,6 +40,8 @@ pub const PACKAGE: &str = "package-x-generic-symbolic"; pub const PAN_DOWN: &str = "pan-down-symbolic"; pub const PREFERENCES_SYSTEM: &str = "preferences-system-symbolic"; pub const PREFERENCES_SYSTEM_TIME: &str = "preferences-system-time-symbolic"; +// Adwaita's only key glyph. +pub const PRIMARY_KEY: &str = "dialog-password-symbolic"; pub const PROCESS_STOP: &str = "process-stop-symbolic"; pub const SECURITY_HIGH: &str = "security-high-symbolic"; pub const STARRED: &str = "starred-symbolic"; @@ -122,6 +122,7 @@ pub const ALL: &[&str] = &[ PAN_DOWN, PREFERENCES_SYSTEM, PREFERENCES_SYSTEM_TIME, + PRIMARY_KEY, PROCESS_STOP, SECURITY_HIGH, SIDEBAR_SHOW, diff --git a/linux/data/resources/style.css b/linux/data/resources/style.css index 37eab09f2f..4c92a7f3e9 100644 --- a/linux/data/resources/style.css +++ b/linux/data/resources/style.css @@ -219,12 +219,3 @@ tp-diagram-canvas > .tp-diagram-border { tp-diagram-canvas > .tp-diagram-accent { color: var(--accent-color); } - -/* A field's type in the row details, as a badge beside its name. */ -.field-type { - font-size: smaller; - padding: 1px 6px; - border-radius: 6px; - background-color: color-mix(in srgb, currentColor 10%, transparent); - opacity: 0.8; -} From d83d8ba0c076ac994ba82c7439cdc93eebc25ba8 Mon Sep 17 00:00:00 2001 From: Ngo Quoc Dat Date: Sun, 8 Nov 2026 20:14:05 +0700 Subject: [PATCH 06/11] fix(linux-grid): add a symbolic type marker to row details --- .../crates/app/src/ui/data_grid/row_detail/fields.rs | 12 +++++++++--- .../crates/app/src/ui/data_grid/row_detail/tests.rs | 12 +++++++++++- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/linux/crates/app/src/ui/data_grid/row_detail/fields.rs b/linux/crates/app/src/ui/data_grid/row_detail/fields.rs index fc38047a6c..b2b4b16a2e 100644 --- a/linux/crates/app/src/ui/data_grid/row_detail/fields.rs +++ b/linux/crates/app/src/ui/data_grid/row_detail/fields.rs @@ -97,7 +97,7 @@ fn field_row() -> gtk::Box { .build(); name.add_css_class("dimmed"); let edited = marker(icons::DOCUMENT_EDIT); - // The colour the grid and the value below give a pending value. + // Match the pending value beneath the marker. edited.add_css_class("warning"); let kind = gtk::Label::builder() .xalign(1.0) @@ -105,11 +105,17 @@ fn field_row() -> gtk::Box { .build(); kind.add_css_class("caption"); kind.add_css_class("dimmed"); + let type_icon = marker(icons::TEXT_X_GENERIC); + type_icon.set_visible(true); + type_icon.add_css_class("dimmed"); + let type_box = gtk::Box::new(gtk::Orientation::Horizontal, 3); + type_box.append(&type_icon); + type_box.append(&kind); let top = gtk::Box::new(gtk::Orientation::Horizontal, 6); top.append(&key); top.append(&name); top.append(&edited); - top.append(&kind); + top.append(&type_box); let value = gtk::Inscription::builder() .hexpand(true) .min_chars(1) @@ -141,7 +147,7 @@ fn field_parts(row: >k::Widget) -> Option { let key = top.first_child()?; let name = key.next_sibling()?; let edited = name.next_sibling()?; - let kind = edited.next_sibling()?; + let kind = edited.next_sibling()?.last_child()?; Some(FieldParts { key: key.downcast().ok()?, name: name.downcast().ok()?, diff --git a/linux/crates/app/src/ui/data_grid/row_detail/tests.rs b/linux/crates/app/src/ui/data_grid/row_detail/tests.rs index 8d0a213f14..fec52081c0 100644 --- a/linux/crates/app/src/ui/data_grid/row_detail/tests.rs +++ b/linux/crates/app/src/ui/data_grid/row_detail/tests.rs @@ -1457,6 +1457,8 @@ fn a_field_marks_its_primary_key_and_a_pending_edit() { assert!(marks(&pane, 0, key_mark)); assert!(!marks(&pane, 1, key_mark)); assert!(!marks(&pane, 1, edit_mark)); + assert!(marks(&pane, 0, crate::ui::icons::TEXT_X_GENERIC)); + assert!(marks(&pane, 1, crate::ui::icons::TEXT_X_GENERIC)); let delta = grid.tracker.apply(TrackerEdit::Cell { row_key: key(1), @@ -1468,10 +1470,15 @@ fn a_field_marks_its_primary_key_and_a_pending_edit() { drain_main_context(); assert!(marks(&pane, 1, edit_mark)); assert!(!marks(&pane, 0, edit_mark)); + assert_eq!( + drawn_field(&pane, 1).accessible_description().as_deref(), + Some("changed, Modified") + ); grid.grid.undo(); drain_main_context(); assert!(!marks(&pane, 1, edit_mark), "the pencil outlived the undo"); + assert_eq!(drawn_field(&pane, 1).accessible_description().as_deref(), Some("A")); } #[gtk4::test] @@ -1480,7 +1487,10 @@ fn a_field_names_its_type_and_its_key_to_a_screen_reader() { grid.focus(0, 1); drain_main_context(); - assert_eq!(drawn_field(&pane, 0).accessible_label().as_deref(), Some("id, integer, primary key")); + assert_eq!( + drawn_field(&pane, 0).accessible_label().as_deref(), + Some("id, integer, primary key") + ); assert_eq!(drawn_field(&pane, 1).accessible_label().as_deref(), Some("name, text")); let result_column = GridColumn { catalog: None, From 9e863bd690af4ac8705e63f386aba85314529295 Mon Sep 17 00:00:00 2001 From: Ngo Quoc Dat Date: Sun, 8 Nov 2026 21:34:06 +0700 Subject: [PATCH 07/11] fix(linux-grid): compare accessible field text as strings --- .../crates/app/src/ui/data_grid/row_detail/tests.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/linux/crates/app/src/ui/data_grid/row_detail/tests.rs b/linux/crates/app/src/ui/data_grid/row_detail/tests.rs index fec52081c0..f6dc3be7e4 100644 --- a/linux/crates/app/src/ui/data_grid/row_detail/tests.rs +++ b/linux/crates/app/src/ui/data_grid/row_detail/tests.rs @@ -1471,14 +1471,14 @@ fn a_field_marks_its_primary_key_and_a_pending_edit() { assert!(marks(&pane, 1, edit_mark)); assert!(!marks(&pane, 0, edit_mark)); assert_eq!( - drawn_field(&pane, 1).accessible_description().as_deref(), - Some("changed, Modified") + drawn_field(&pane, 1).accessible_description().as_str(), + "changed, Modified" ); grid.grid.undo(); drain_main_context(); assert!(!marks(&pane, 1, edit_mark), "the pencil outlived the undo"); - assert_eq!(drawn_field(&pane, 1).accessible_description().as_deref(), Some("A")); + assert_eq!(drawn_field(&pane, 1).accessible_description().as_str(), "A"); } #[gtk4::test] @@ -1488,10 +1488,10 @@ fn a_field_names_its_type_and_its_key_to_a_screen_reader() { drain_main_context(); assert_eq!( - drawn_field(&pane, 0).accessible_label().as_deref(), - Some("id, integer, primary key") + drawn_field(&pane, 0).accessible_label().as_str(), + "id, integer, primary key" ); - assert_eq!(drawn_field(&pane, 1).accessible_label().as_deref(), Some("name, text")); + assert_eq!(drawn_field(&pane, 1).accessible_label().as_str(), "name, text"); let result_column = GridColumn { catalog: None, ..column_of(named("id", "integer", true)) From 22e207809f746b69db44ab37535e55ce412afd4a Mon Sep 17 00:00:00 2001 From: Ngo Quoc Dat Date: Sun, 8 Nov 2026 21:43:18 +0700 Subject: [PATCH 08/11] fix(linux-grid): refresh row detail filters with their data --- linux/changelog.d/4113.added.md | 2 +- .../app/src/ui/data_grid/row_detail/fields.rs | 92 +++++++---- .../app/src/ui/data_grid/row_detail/imp.rs | 3 +- .../app/src/ui/data_grid/row_detail/mod.rs | 1 + .../app/src/ui/data_grid/row_detail/tests.rs | 149 +++++++++++++++++- linux/data/resources/ui/row-detail-pane.ui | 43 +++-- 6 files changed, 247 insertions(+), 43 deletions(-) diff --git a/linux/changelog.d/4113.added.md b/linux/changelog.d/4113.added.md index 67cebaf25c..4bf0ad7a81 100644 --- a/linux/changelog.d/4113.added.md +++ b/linux/changelog.d/4113.added.md @@ -1 +1 @@ -The row details search their fields by name and can show only the edited ones. +Search Row Details by field name or value, or show only fields with unsaved edits. diff --git a/linux/crates/app/src/ui/data_grid/row_detail/fields.rs b/linux/crates/app/src/ui/data_grid/row_detail/fields.rs index 6eef08d31e..cedceb0b8b 100644 --- a/linux/crates/app/src/ui/data_grid/row_detail/fields.rs +++ b/linux/crates/app/src/ui/data_grid/row_detail/fields.rs @@ -192,7 +192,7 @@ impl RowDetailPane { #[weak(rename_to = pane)] self, #[upgrade_or] - true, + false, move |item| pane.field_shown(field_of(Some(item.clone()))) )); imp.field_search.connect_search_changed(glib::clone!( @@ -200,6 +200,29 @@ impl RowDetailPane { self, move |_| pane.refilter_fields() )); + imp.field_search.set_key_capture_widget(Some(&imp.field_list.get())); + imp.field_search.connect_stop_search(glib::clone!( + #[weak(rename_to = pane)] + self, + move |entry| { + if !entry.text().is_empty() { + entry.set_text(""); + } else if pane.grid().is_some_and(|grid| grid.imp().split_view.is_collapsed()) { + pane.imp().close_button.emit_clicked(); + } + } + )); + imp.field_search.connect_activate(glib::clone!( + #[weak(rename_to = pane)] + self, + move |_| { + pane.refilter_fields(); + if pane.imp().filtered.n_items() > 0 { + pane.imp().selection.set_selected(0); + pane.focus_value(); + } + } + )); imp.edited_toggle.connect_toggled(glib::clone!( #[weak(rename_to = pane)] self, @@ -256,39 +279,54 @@ impl RowDetailPane { } pub(super) fn redraw_fields(&self) { + self.refilter_fields(); let bound: Vec = self.imp().bound.borrow().clone(); for item in &bound { self.draw_field(item); } - // An edit made or undone changes which fields are edited. - if self.imp().edited_toggle.is_active() { - self.refilter_fields(); - } } - fn refilter_fields(&self) { - self.imp().field_filter.changed(gtk::FilterChange::Different); + pub(super) fn refilter_fields(&self) { + let imp = self.imp(); + let has_edits = self.grid().zip(self.current_row()).is_some_and(|(grid, row)| { + grid.grid_columns().iter().any(|column| { + let mark = grid.tracked().mark(&row, column.index); + mark.state == CellState::Modified && !mark.row_deleted + }) + }); + imp.edited_toggle + .set_sensitive(has_edits || imp.edited_toggle.is_active()); + // A changed filter may move the selected position without a user picking a field. + let syncing = imp.syncing.replace(true); + imp.field_filter.changed(gtk::FilterChange::Different); + self.select_in_list(imp.field.get()); + imp.syncing.set(syncing); + imp.field_results.set_visible_child_name(match imp.filtered.n_items() { + 0 => "empty", + _ => "fields", + }); } - /// Whether the search and the edited-only toggle leave `column`'s - /// field in the list. fn field_shown(&self, column: Option) -> bool { let imp = self.imp(); - let (Some(grid), Some(column)) = (self.grid(), column) else { - return true; + let (Some(grid), Some(column), Some(row)) = (self.grid(), column, self.current_row()) else { + return false; }; let Some(column) = grid.grid_columns().get(column).cloned() else { - return true; - }; - let wanted = imp.field_search.text().to_lowercase(); - if !wanted.is_empty() && !column.name.to_lowercase().contains(&wanted) { return false; + }; + if imp.edited_toggle.is_active() { + let mark = grid.tracked().mark(&row, column.index); + if mark.state != CellState::Modified || mark.row_deleted { + return false; + } } - if !imp.edited_toggle.is_active() { + let wanted = imp.field_search.text().to_lowercase(); + if wanted.is_empty() || column.name.to_lowercase().contains(&wanted) { return true; } - self.current_row() - .is_some_and(|row| field_value(&grid.tracked(), &row, &column).modified) + let value = field_value(&grid.tracked(), &row, &column); + !value.null && value.text.to_lowercase().contains(&wanted) } fn draw_field(&self, item: >k::ListItem) { @@ -372,7 +410,6 @@ impl RowDetailPane { pub(super) fn select_in_list(&self, column: Option) { let imp = self.imp(); - // The list as shown, which the search may have narrowed. let shown = &imp.selection; let position = column .and_then(|column| (0..shown.n_items()).find(|position| field_of(shown.item(*position)) == Some(column))) @@ -380,9 +417,9 @@ impl RowDetailPane { if imp.selection.selected() == position { return; } - imp.syncing.set(true); + let syncing = imp.syncing.replace(true); imp.selection.set_selected(position); - imp.syncing.set(false); + imp.syncing.set(syncing); if position != gtk::INVALID_LIST_POSITION { imp.field_list.scroll_to(position, gtk::ListScrollFlags::NONE, None); } @@ -418,17 +455,15 @@ impl RowDetailPane { move || { pane.imp().sync_queued.set(false); pane.watch_column_visibility(); - if pane.sync_fields() { - pane.render(); - } + pane.sync_fields(); + pane.render(); } )); } - /// Put the fields in the grid's column order. `true` when it changed. - pub(super) fn sync_fields(&self) -> bool { + pub(super) fn sync_fields(&self) { let Some(grid) = self.grid() else { - return false; + return; }; let imp = self.imp(); let wanted = field_order(&grid.shown_columns(), grid.grid_columns().len()); @@ -437,7 +472,7 @@ impl RowDetailPane { .filter_map(|position| field_of(store.item(position))) .collect(); if held == wanted { - return false; + return; } let items: Vec = wanted.into_iter().map(glib::BoxedAnyObject::new).collect(); imp.syncing.set(true); @@ -448,7 +483,6 @@ impl RowDetailPane { imp.field.set(None); } self.select_in_list(imp.field.get()); - true } fn watch_column_visibility(&self) { diff --git a/linux/crates/app/src/ui/data_grid/row_detail/imp.rs b/linux/crates/app/src/ui/data_grid/row_detail/imp.rs index 39ea89ac9e..7f9b51ba0a 100644 --- a/linux/crates/app/src/ui/data_grid/row_detail/imp.rs +++ b/linux/crates/app/src/ui/data_grid/row_detail/imp.rs @@ -41,6 +41,8 @@ pub struct RowDetailPane { #[template_child] pub field_list: TemplateChild, #[template_child] + pub field_results: TemplateChild, + #[template_child] pub field_search: TemplateChild, #[template_child] pub edited_toggle: TemplateChild, @@ -84,7 +86,6 @@ pub struct RowDetailPane { pub grid: glib::WeakRef, pub fields: Fields, pub selection: gtk::SingleSelection, - /// The fields the search and the edited-only toggle leave in the list. pub filtered: gtk::FilterListModel, pub field_filter: gtk::CustomFilter, /// The row the pane shows, while it has one. diff --git a/linux/crates/app/src/ui/data_grid/row_detail/mod.rs b/linux/crates/app/src/ui/data_grid/row_detail/mod.rs index 7804cc47ca..68aa409846 100644 --- a/linux/crates/app/src/ui/data_grid/row_detail/mod.rs +++ b/linux/crates/app/src/ui/data_grid/row_detail/mod.rs @@ -282,6 +282,7 @@ impl RowDetailPane { } fn show_nothing(&self) { + self.refilter_fields(); self.imp().stack.set_visible_child_name("empty"); self.imp().loaded.take(); } diff --git a/linux/crates/app/src/ui/data_grid/row_detail/tests.rs b/linux/crates/app/src/ui/data_grid/row_detail/tests.rs index 96b424f0f5..1f447df29e 100644 --- a/linux/crates/app/src/ui/data_grid/row_detail/tests.rs +++ b/linux/crates/app/src/ui/data_grid/row_detail/tests.rs @@ -23,10 +23,10 @@ use crate::test_support::{ descendants, drain_main_context, finish_on_main, test_backend_records_properties, unlabelled_icon_buttons, wait_until, }; -use crate::ui::data_grid::GridRequest; use crate::ui::data_grid::test_grid::{ Grid, GridSpec, WAIT, focus_in_grid, key, named, page, persisted, text, two_text_columns, two_text_values, }; +use crate::ui::data_grid::{GridRequest, GridSorting}; use crate::ui::error_text::edit_parse_message; fn pane_of(grid: &Grid) -> RowDetailPane { @@ -1499,8 +1499,6 @@ fn a_field_names_its_type_and_its_key_to_a_screen_reader() { assert_eq!(field_label(&result_column), "id, integer"); } -/// The search narrows the fields to the names it matches, and the toggle -/// to the ones holding an edit. #[gtk4::test] fn the_field_search_and_the_edited_toggle_narrow_the_list() { let (grid, pane) = opened(two_text_columns(), two_text_values()); @@ -1508,6 +1506,7 @@ fn the_field_search_and_the_edited_toggle_narrow_the_list() { let imp = pane.imp(); let listed = || imp.selection.n_items(); assert_eq!(listed(), 2); + assert!(!imp.edited_toggle.is_sensitive()); // The entry reports a search after its own short delay. imp.field_search.set_text("NAM"); @@ -1528,4 +1527,148 @@ fn the_field_search_and_the_edited_toggle_narrow_the_list() { grid.grid.apply_delta(&delta); drain_main_context(); assert_eq!(listed(), 1, "the edited field joins the list"); + grid.grid.undo(); + drain_main_context(); + assert_eq!(listed(), 0, "undo removes the field from the edited filter"); + assert!( + imp.edited_toggle.is_sensitive(), + "the active filter can always be turned off" + ); + imp.edited_toggle.set_active(false); + assert_eq!(listed(), 2); + assert!(!imp.edited_toggle.is_sensitive()); +} + +fn listed_columns(pane: &RowDetailPane) -> Vec { + let model = &pane.imp().filtered; + (0..model.n_items()) + .map(|position| { + let boxed = model + .item(position) + .and_downcast::() + .expect("a field"); + *boxed.borrow::() + }) + .collect() +} + +fn search_fields(pane: &RowDetailPane, query: &str) { + pane.imp().field_search.set_text(query); + pane.imp().field_search.emit_by_name::<()>("search-changed", &[]); + drain_main_context(); +} + +#[gtk4::test] +fn field_search_refilters_a_new_schema_with_the_same_column_indices() { + let (grid, pane) = opened(two_text_columns(), two_text_values()); + grid.focus(0, 1); + search_fields(&pane, "nam"); + assert_eq!(listed_columns(&pane), vec![1]); + + let mut columns = grid.columns.to_vec(); + columns[0].name = "name_id".into(); + columns[1].name = "label".into(); + grid.grid + .set_columns(columns.into(), GridSorting::Server { initial: None }, None); + grid.grid.replace_rows(persisted(&two_text_values()), 0); + grid.focus(0, 0); + drain_main_context(); + + assert_eq!(listed_columns(&pane), vec![0]); + assert_eq!( + drawn_field(&pane, 0).accessible_label().as_str(), + "name_id, integer, primary key" + ); +} + +#[gtk4::test] +fn field_search_follows_row_selection_replacement_and_edits() { + let (grid, pane) = opened(two_text_columns(), two_text_values()); + grid.focus(0, 1); + search_fields(&pane, "B"); + assert!(listed_columns(&pane).is_empty()); + pane.imp().field_search.grab_focus(); + grid.grid.selection().select_item(1, true); + drain_main_context(); + assert_eq!(listed_columns(&pane), vec![1]); + + grid.grid + .replace_rows(persisted(&[vec![Value::Int(2), Value::Text("C".into())]]), 0); + drain_main_context(); + assert!(listed_columns(&pane).is_empty()); + let delta = grid.tracker.apply(TrackerEdit::Cell { + row_key: key(2), + col: 1, + original: Value::Text("C".into()), + value: text("B"), + }); + grid.grid.apply_delta(&delta); + drain_main_context(); + assert_eq!(listed_columns(&pane), vec![1]); + grid.grid.undo(); + drain_main_context(); + assert!(listed_columns(&pane).is_empty()); + grid.grid.clear_rows(); + drain_main_context(); + assert!(listed_columns(&pane).is_empty()); + assert_eq!(pane.imp().stack.visible_child_name().as_deref(), Some("empty")); +} + +#[gtk4::test] +fn filtering_keeps_the_selected_field_and_restores_its_list_selection() { + let (grid, pane) = opened(two_text_columns(), two_text_values()); + grid.focus(0, 1); + pane.imp().field_search.grab_focus(); + search_fields(&pane, "id"); + assert_eq!(selected_field(&pane), Some(1)); + assert_eq!(pane.typed_text(), "A"); + assert_eq!(pane.imp().selection.selected(), gtk::INVALID_LIST_POSITION); + assert!(crate::ui::a11y::holds_focus(&pane.imp().field_search.get())); + + search_fields(&pane, "no such field"); + assert_eq!(pane.imp().field_results.visible_child_name().as_deref(), Some("empty")); + search_fields(&pane, ""); + assert_eq!(selected_field(&pane), Some(1)); + assert_eq!(pane.imp().selection.selected(), 1); + assert_eq!(pane.imp().field_results.visible_child_name().as_deref(), Some("fields")); +} + +#[gtk4::test] +fn search_keys_and_tab_order_reach_the_filter_list_and_value() { + let (grid, pane) = opened(two_text_columns(), two_text_values()); + crate::test_support::KeyInjector::focus_only(&grid.window); + take_keyboard(&grid); + grid.focus(0, 1); + let delta = grid.tracker.apply(TrackerEdit::Cell { + row_key: key(1), + col: 1, + original: Value::Text("A".into()), + value: text("changed"), + }); + grid.grid.apply_delta(&delta); + pane.imp().field_search.grab_focus(); + let keys = crate::test_support::KeyInjector::connect().expect("an X11 display"); + keys.press(gdk::Key::Tab, gdk::ModifierType::empty()).expect("Tab"); + wait_until(WAIT, || crate::ui::a11y::holds_focus(&pane.imp().edited_toggle.get())).expect("Tab to the filter"); + keys.press(gdk::Key::Tab, gdk::ModifierType::empty()).expect("Tab"); + wait_until(WAIT, || crate::ui::a11y::holds_focus(&pane.imp().field_list.get())).expect("Tab to the list"); + keys.press(gdk::Key::n, gdk::ModifierType::empty()) + .expect("type to search"); + wait_until(WAIT, || pane.imp().field_search.text() == "n").expect("typing in the list searches"); + keys.press(gdk::Key::Escape, gdk::ModifierType::empty()) + .expect("Escape"); + wait_until(WAIT, || pane.imp().field_search.text().is_empty()).expect("Escape clears"); + wait_until(WAIT, || listed_columns(&pane).len() == 2).expect("clearing restores all fields"); + search_fields(&pane, "name"); + keys.press(gdk::Key::Return, gdk::ModifierType::empty()).expect("Enter"); + wait_until(WAIT, || crate::ui::a11y::holds_focus(&pane.imp().value_view.get())).expect("Enter opens the result"); + assert_eq!(selected_field(&pane), Some(1)); + assert_eq!(pane.typed_text(), "changed"); + + grid.grid.imp().split_view.set_collapsed(true); + pane.imp().field_search.grab_focus(); + search_fields(&pane, ""); + keys.press(gdk::Key::Escape, gdk::ModifierType::empty()) + .expect("Escape"); + wait_until(WAIT, || !grid.grid.imp().split_view.shows_sidebar()).expect("Escape closes the empty overlay search"); } diff --git a/linux/data/resources/ui/row-detail-pane.ui b/linux/data/resources/ui/row-detail-pane.ui index d8870c5d12..133dfbeccd 100644 --- a/linux/data/resources/ui/row-detail-pane.ui +++ b/linux/data/resources/ui/row-detail-pane.ui @@ -159,17 +159,42 @@ - + true - never - 120 - - - - Fields - + + + fields + + + never + 120 + + + + Fields + + + + + - + + + + empty + + + No Matching Fields + true + 12 + 12 + + + + + From a34198c3fe9e08258f141eb7077c1b1850e70c0b Mon Sep 17 00:00:00 2001 From: Ngo Quoc Dat Date: Sun, 8 Nov 2026 21:46:00 +0700 Subject: [PATCH 09/11] fix(linux-grid): focus the row detail search when typing --- linux/crates/app/src/ui/data_grid/row_detail/fields.rs | 3 +++ linux/crates/app/src/ui/data_grid/row_detail/tests.rs | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/linux/crates/app/src/ui/data_grid/row_detail/fields.rs b/linux/crates/app/src/ui/data_grid/row_detail/fields.rs index cedceb0b8b..500c6773d1 100644 --- a/linux/crates/app/src/ui/data_grid/row_detail/fields.rs +++ b/linux/crates/app/src/ui/data_grid/row_detail/fields.rs @@ -201,6 +201,9 @@ impl RowDetailPane { move |_| pane.refilter_fields() )); imp.field_search.set_key_capture_widget(Some(&imp.field_list.get())); + imp.field_search.connect_search_started(|entry| { + entry.grab_focus(); + }); imp.field_search.connect_stop_search(glib::clone!( #[weak(rename_to = pane)] self, diff --git a/linux/crates/app/src/ui/data_grid/row_detail/tests.rs b/linux/crates/app/src/ui/data_grid/row_detail/tests.rs index 1f447df29e..82ed39041c 100644 --- a/linux/crates/app/src/ui/data_grid/row_detail/tests.rs +++ b/linux/crates/app/src/ui/data_grid/row_detail/tests.rs @@ -1655,6 +1655,10 @@ fn search_keys_and_tab_order_reach_the_filter_list_and_value() { keys.press(gdk::Key::n, gdk::ModifierType::empty()) .expect("type to search"); wait_until(WAIT, || pane.imp().field_search.text() == "n").expect("typing in the list searches"); + assert!(crate::ui::a11y::holds_focus(&pane.imp().field_search.get())); + keys.press(gdk::Key::space, gdk::ModifierType::empty()) + .expect("a space in the query"); + wait_until(WAIT, || pane.imp().field_search.text() == "n ").expect("the entry keeps spaces in the query"); keys.press(gdk::Key::Escape, gdk::ModifierType::empty()) .expect("Escape"); wait_until(WAIT, || pane.imp().field_search.text().is_empty()).expect("Escape clears"); From 4f0ee65cf505a64e2131d0894bb455e1e4e109a5 Mon Sep 17 00:00:00 2001 From: Ngo Quoc Dat Date: Sun, 8 Nov 2026 22:26:50 +0700 Subject: [PATCH 10/11] test(linux-grid): wait for row detail controls before tabbing --- .../app/src/ui/data_grid/row_detail/tests.rs | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/linux/crates/app/src/ui/data_grid/row_detail/tests.rs b/linux/crates/app/src/ui/data_grid/row_detail/tests.rs index 82ed39041c..f8626a91dd 100644 --- a/linux/crates/app/src/ui/data_grid/row_detail/tests.rs +++ b/linux/crates/app/src/ui/data_grid/row_detail/tests.rs @@ -1646,7 +1646,21 @@ fn search_keys_and_tab_order_reach_the_filter_list_and_value() { value: text("changed"), }); grid.grid.apply_delta(&delta); - pane.imp().field_search.grab_focus(); + // GTK orders Tab stops by their allocation, which follows the pane opening. + wait_until(WAIT, || { + pane.imp().field_search.is_mapped() + && pane.imp().field_search.width() > 0 + && pane.imp().field_search.height() > 0 + && pane.imp().edited_toggle.is_mapped() + && pane.imp().edited_toggle.width() > 0 + && pane.imp().edited_toggle.height() > 0 + && pane.imp().field_list.width() > 0 + }) + .expect("the search controls are laid out"); + crate::test_support::after_next_frame(&grid.window); + assert!(pane.imp().edited_toggle.is_sensitive()); + assert!(pane.imp().field_search.grab_focus()); + assert!(crate::ui::a11y::holds_focus(&pane.imp().field_search.get())); let keys = crate::test_support::KeyInjector::connect().expect("an X11 display"); keys.press(gdk::Key::Tab, gdk::ModifierType::empty()).expect("Tab"); wait_until(WAIT, || crate::ui::a11y::holds_focus(&pane.imp().edited_toggle.get())).expect("Tab to the filter"); From 8ec955a375dc59fd5e3dcbe4a75fc5d885fc7f01 Mon Sep 17 00:00:00 2001 From: Ngo Quoc Dat Date: Mon, 9 Nov 2026 16:46:52 +0700 Subject: [PATCH 11/11] fix(linux-workspace): drop the unfulfilled too_many_lines expectation on update --- linux/crates/app/src/ui/workspace/mod.rs | 4 ---- 1 file changed, 4 deletions(-) diff --git a/linux/crates/app/src/ui/workspace/mod.rs b/linux/crates/app/src/ui/workspace/mod.rs index 97905d18c9..1546b9b017 100644 --- a/linux/crates/app/src/ui/workspace/mod.rs +++ b/linux/crates/app/src/ui/workspace/mod.rs @@ -1330,10 +1330,6 @@ impl WorkspaceModel { } } - #[expect( - clippy::too_many_lines, - reason = "Each workspace input dispatches to its own handler" - )] fn update(&mut self, msg: WorkspaceInput) { match msg { WorkspaceInput::HealthChanged(health) => self.refresh_health_banner(&health),