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/14] 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/14] 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/14] 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/14] 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/14] 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/14] 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/14] 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/14] 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/14] 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/14] 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 4ad9ecaad6f1505252c4946f20dc61945f0b6f1f Mon Sep 17 00:00:00 2001 From: sedax90 <5001801+sedax90@users.noreply.github.com> Date: Mon, 9 Nov 2026 09:02:33 +0100 Subject: [PATCH 11/14] feat(linux-grid): draw a row detail field as a name over its value, with a copy button --- .../app/src/ui/data_grid/row_detail/fields.rs | 40 +++++++++++++++++-- .../app/src/ui/data_grid/row_detail/tests.rs | 26 ++++++++++++ linux/data/resources/style.css | 23 +++++++++++ linux/data/resources/ui/row-detail-pane.ui | 3 ++ 4 files changed, 89 insertions(+), 3 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 500c6773d1..13acd7d6ed 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 @@ -116,11 +116,37 @@ fn field_row() -> gtk::Box { top.append(&name); top.append(&edited); top.append(&type_box); + // A button of the row, not of the list's selection: it copies this + // field's value whatever field the editor below holds. + let copy = gtk::Button::builder() + .icon_name(icons::EDIT_COPY) + .tooltip_text(gettext("Copy Value")) + .valign(gtk::Align::Center) + .build(); + copy.add_css_class("flat"); + copy.add_css_class("circular"); + copy.add_css_class("field-copy"); + copy.update_property(&[gtk::accessible::Property::Label(&gettext("Copy Value"))]); + top.append(©); let value = gtk::Inscription::builder() .hexpand(true) .min_chars(1) .text_overflow(gtk::InscriptionOverflow::EllipsizeEnd) .build(); + value.add_css_class("monospace"); + // The value sits in a field of its own, as macOS's inspector draws it. + let well = gtk::Box::new(gtk::Orientation::Horizontal, 0); + well.add_css_class("field-well"); + well.append(&value); + copy.connect_clicked(glib::clone!( + #[weak] + value, + move |button| { + if let Some(text) = value.text() { + button.clipboard().set_text(&text); + } + } + )); let row = gtk::Box::builder() .orientation(gtk::Orientation::Vertical) .spacing(2) @@ -130,7 +156,7 @@ fn field_row() -> gtk::Box { .margin_end(12) .build(); row.append(&top); - row.append(&value); + row.append(&well); row } @@ -139,6 +165,7 @@ struct FieldParts { name: gtk::Label, edited: gtk::Image, kind: gtk::Label, + copy: gtk::Button, value: gtk::Inscription, } @@ -147,13 +174,16 @@ 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()?.last_child()?; + let type_box = edited.next_sibling()?; + let kind = type_box.last_child()?; + let copy = type_box.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()?, + copy: copy.downcast().ok()?, + value: row.last_child()?.first_child()?.downcast().ok()?, }) } @@ -347,6 +377,7 @@ impl RowDetailPane { name, edited, kind, + copy, value: shown, }) = field_parts(&row_box) else { @@ -358,11 +389,14 @@ impl RowDetailPane { item.set_accessible_label(&field_label(&column)); let Some(row) = self.current_row() else { edited.set_visible(false); + copy.set_sensitive(false); shown.set_text(None); return; }; let value = field_value(&grid.tracked(), &row, &column); edited.set_visible(value.modified); + // A stand-in (NULL, DEFAULT, an expression) is not a value to copy. + copy.set_sensitive(!value.placeholder); 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 f8626a91dd..f3115c3d57 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 @@ -1690,3 +1690,29 @@ fn search_keys_and_tab_order_reach_the_filter_list_and_value() { .expect("Escape"); wait_until(WAIT, || !grid.grid.imp().split_view.shows_sidebar()).expect("Escape closes the empty overlay search"); } + +#[gtk4::test] +fn a_fields_copy_button_copies_its_own_value_not_the_selected_ones() { + let (grid, pane) = opened(two_text_columns(), two_text_values()); + grid.focus(1, 1); + drain_main_context(); + + let row = drawn_field(&pane, 0).child().expect("the field's row"); + let copy = descendants(&row) + .into_iter() + .filter_map(|widget| widget.downcast::().ok()) + .find(|button| button.has_css_class("field-copy")) + .expect("the copy button"); + assert!(copy.is_sensitive()); + copy.emit_clicked(); + + let clipboard = copy.clipboard(); + let copied = finish_on_main(WAIT, async move { clipboard.read_text_future().await }) + .expect("the clipboard to answer") + .expect("text on the clipboard"); + assert_eq!( + copied.as_deref(), + Some("2"), + "the first field's value, with the second selected" + ); +} diff --git a/linux/data/resources/style.css b/linux/data/resources/style.css index 4c92a7f3e9..3c10aeaee1 100644 --- a/linux/data/resources/style.css +++ b/linux/data/resources/style.css @@ -219,3 +219,26 @@ tp-diagram-canvas > .tp-diagram-border { tp-diagram-canvas > .tp-diagram-accent { color: var(--accent-color); } + +/* Row details: each field is a name over its value in a field of its own, + as macOS's inspector draws it. The selection marks the field the editor + below holds with its outline, not a fill over the whole row. */ +.row-detail-fields, +.row-detail-fields > row, +.row-detail-fields > row:hover, +.row-detail-fields > row:selected { + background: none; +} + +.row-detail-fields .field-well { + background-color: var(--view-bg-color); + border: 1px solid alpha(currentColor, 0.2); + border-radius: 6px; + padding: 4px 8px; + min-height: 22px; +} + +.row-detail-fields > row:selected .field-well { + border-color: var(--accent-color); + box-shadow: inset 0 0 0 1px var(--accent-color); +} diff --git a/linux/data/resources/ui/row-detail-pane.ui b/linux/data/resources/ui/row-detail-pane.ui index 133dfbeccd..677d6f7bce 100644 --- a/linux/data/resources/ui/row-detail-pane.ui +++ b/linux/data/resources/ui/row-detail-pane.ui @@ -170,6 +170,9 @@ 120 + Fields From 4f42a158595e523e9fbdfd49ccb53c768cf64099 Mon Sep 17 00:00:00 2001 From: sedax90 <5001801+sedax90@users.noreply.github.com> Date: Mon, 9 Nov 2026 09:08:21 +0100 Subject: [PATCH 12/14] chore(linux): changelog for the row details design --- linux/changelog.d/4156.changed.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 linux/changelog.d/4156.changed.md diff --git a/linux/changelog.d/4156.changed.md b/linux/changelog.d/4156.changed.md new file mode 100644 index 0000000000..544dabadea --- /dev/null +++ b/linux/changelog.d/4156.changed.md @@ -0,0 +1 @@ +Row details draw each field as a name over its value in a field of its own, with a button that copies the value, as macOS's inspector does. From 2e485aaea4ef43138a9dcb95313cf908d4c1f54b Mon Sep 17 00:00:00 2001 From: Ngo Quoc Dat Date: Tue, 10 Nov 2026 04:13:45 +0700 Subject: [PATCH 13/14] fix(linux-grid): copy a row detail field's whole value through the grid's Copy --- linux/changelog.d/4156.added.md | 1 + linux/changelog.d/4156.changed.md | 1 - .../app/src/ui/data_grid/row_detail/fields.rs | 75 ++++++++++++++++--- .../app/src/ui/data_grid/row_detail/tests.rs | 73 ++++++++++++++++++ linux/data/resources/ui/row-detail-pane.ui | 4 + 5 files changed, 144 insertions(+), 10 deletions(-) create mode 100644 linux/changelog.d/4156.added.md delete mode 100644 linux/changelog.d/4156.changed.md diff --git a/linux/changelog.d/4156.added.md b/linux/changelog.d/4156.added.md new file mode 100644 index 0000000000..d528d5a272 --- /dev/null +++ b/linux/changelog.d/4156.added.md @@ -0,0 +1 @@ +Each field in the row details has a button that copies its whole value. diff --git a/linux/changelog.d/4156.changed.md b/linux/changelog.d/4156.changed.md deleted file mode 100644 index 544dabadea..0000000000 --- a/linux/changelog.d/4156.changed.md +++ /dev/null @@ -1 +0,0 @@ -Row details draw each field as a name over its value in a field of its own, with a button that copies the value, as macOS's inspector does. 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 b06cfdb1c5..1fddc6bedd 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 @@ -9,6 +9,7 @@ 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::selection::Target; use crate::ui::data_grid::tracked_values::cell_description; use crate::ui::data_grid::{DataGrid, GridRow, ServerValue, TrackedValues}; use crate::ui::handler_guard::HandlerGuard; @@ -121,16 +122,32 @@ fn field_row() -> gtk::Box { .min_chars(1) .text_overflow(gtk::InscriptionOverflow::EllipsizeEnd) .build(); - let row = gtk::Box::builder() + // As the grid's cells and the value editor draw a value. + value.add_css_class("monospace"); + let content = gtk::Box::builder() .orientation(gtk::Orientation::Vertical) .spacing(2) + .hexpand(true) + .valign(gtk::Align::Center) + .build(); + content.append(&top); + content.append(&value); + // A suffix of the row, as on a libadwaita property row. + let copy = gtk::Button::builder() + .icon_name(icons::EDIT_COPY) + .valign(gtk::Align::Center) + .build(); + copy.add_css_class("flat"); + crate::ui::a11y::describe_icon_button(©, &gettext("Copy Value"), None); + let row = gtk::Box::builder() + .spacing(6) .margin_top(6) .margin_bottom(6) .margin_start(12) .margin_end(12) .build(); - row.append(&top); - row.append(&value); + row.append(&content); + row.append(©); row } @@ -140,10 +157,12 @@ struct FieldParts { edited: gtk::Image, kind: gtk::Label, value: gtk::Inscription, + copy: gtk::Button, } fn field_parts(row: >k::Widget) -> Option { - let top = row.first_child()?; + let content = row.first_child()?; + let top = content.first_child()?; let key = top.first_child()?; let name = key.next_sibling()?; let edited = name.next_sibling()?; @@ -153,7 +172,8 @@ fn field_parts(row: >k::Widget) -> Option { name: name.downcast().ok()?, edited: edited.downcast().ok()?, kind: kind.downcast().ok()?, - value: row.last_child()?.downcast().ok()?, + value: top.next_sibling()?.downcast().ok()?, + copy: content.next_sibling()?.downcast().ok()?, }) } @@ -254,11 +274,32 @@ impl RowDetailPane { fn field_factory(&self) -> gtk::SignalListItemFactory { let factory = gtk::SignalListItemFactory::new(); - factory.connect_setup(|_, item| { - if let Some(item) = item.downcast_ref::() { - item.set_child(Some(&field_row())); + factory.connect_setup(glib::clone!( + #[weak(rename_to = pane)] + self, + move |_, item| { + let Some(item) = item.downcast_ref::() else { + return; + }; + let row = field_row(); + if let Some(parts) = field_parts(row.upcast_ref()) { + // The grid's Copy, so the whole value goes rather than + // the text the field draws, which cuts a long one. + parts.copy.connect_clicked(glib::clone!( + #[weak] + pane, + #[weak] + item, + move |_| { + if let Some(column) = field_of(item.item()) { + pane.act_on_field(column, "copy"); + } + } + )); + } + item.set_child(Some(&row)); } - }); + )); factory.connect_bind(glib::clone!( #[weak(rename_to = pane)] self, @@ -352,6 +393,7 @@ impl RowDetailPane { edited, kind, value: shown, + .. }) = field_parts(&row_box) else { return; @@ -454,6 +496,21 @@ impl RowDetailPane { .scroll_to(position, Some(&view_column), gtk::ListScrollFlags::FOCUS, None); } + /// Run the grid's `action` on the shown row's `column`, whichever + /// field the editor holds, as a cell menu runs it on its cell. + fn act_on_field(&self, column: usize, action: &str) { + let (Some(grid), Some(row)) = (self.grid(), self.current_pin()) else { + return; + }; + grid.hold_menu_target(Target { + cell: Some((row.clone(), column)), + rows: vec![row], + }); + grid.refresh_actions(); + grid.actions().activate_action(action, None); + grid.release_menu_target_soon(); + } + /// A header drag, a hidden column or a new column set reorders the /// fields once the grid has finished changing its columns. fn schedule_field_sync(&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 a2db47283c..004dbe358c 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 @@ -18,6 +18,7 @@ use super::clock::{ClockField, time_of, with_time}; use super::fields::{field_label, field_order}; use super::value_editor::value_content; use crate::services::change_tracker::RowKey; +use crate::services::grid::display_text::DISPLAY_MAX_CHARS; use crate::services::grid::{CellLock, GridColumn, GridRowId, grid_columns}; use crate::services::tracker_edit::TrackerEdit; use crate::test_support::{ @@ -1836,3 +1837,75 @@ fn search_keys_and_tab_order_reach_the_filter_list_and_value() { .expect("Escape"); wait_until(WAIT, || !grid.grid.imp().split_view.shows_sidebar()).expect("Escape closes the empty overlay search"); } + +fn copy_button(pane: &RowDetailPane, column: usize) -> gtk::Button { + let row = drawn_field(pane, column).child().expect("the field's row"); + descendants(&row) + .into_iter() + .filter_map(|widget| widget.downcast::().ok()) + .find(|button| button.icon_name().as_deref() == Some(crate::ui::icons::EDIT_COPY)) + .expect("the field's copy button") +} + +#[gtk4::test] +fn a_fields_copy_button_copies_its_whole_value_and_leaves_the_editor() { + let long = "x".repeat(DISPLAY_MAX_CHARS + 500); + let (grid, pane) = opened( + three_text_columns(), + vec![vec![Value::Int(1), Value::Text("A".into()), Value::Text(long.clone())]], + ); + grid.focus(0, 1); + drain_main_context(); + let heard: Rc>> = Rc::default(); + let log = heard.clone(); + grid.grid.connect_request(move |_, request| { + if let GridRequest::Toast(text) = request { + log.borrow_mut().push(text); + } + }); + + copy_button(&pane, 2).emit_clicked(); + wait_until(WAIT, || !heard.borrow().is_empty()).expect("the copy lands"); + + let clipboard = grid.grid.clipboard(); + let copied = finish_on_main(WAIT, async move { clipboard.read_text_future().await }) + .expect("the clipboard to answer") + .expect("text on the clipboard"); + assert_eq!( + copied.as_deref().map(str::len), + Some(long.len()), + "the copy took the text the field draws" + ); + assert_eq!(selected_field(&pane), Some(1), "the copy moved the editor"); + assert_eq!(pane.typed_text(), "A"); +} + +/// The arrows go from field to field, so Tab leaves the list once past +/// the focused field's own buttons rather than through every field. +#[gtk4::test] +fn tab_leaves_the_field_list_after_the_focused_field() { + 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 list = pane.imp().field_list.get(); + wait_until(WAIT, || { + pane.imp().field_search.is_mapped() && list.width() > 0 && list.height() > 0 + }) + .expect("the fields are laid out"); + crate::test_support::after_next_frame(&grid.window); + assert!(pane.imp().field_search.grab_focus()); + let keys = crate::test_support::KeyInjector::connect().expect("an X11 display"); + let on_copy = || { + gtk::prelude::GtkWindowExt::focus(&grid.window) + .and_downcast::() + .is_some_and(|button| button.icon_name().as_deref() == Some(crate::ui::icons::EDIT_COPY)) + }; + + keys.press(gdk::Key::Tab, gdk::ModifierType::empty()).expect("Tab"); + wait_until(WAIT, || crate::ui::a11y::holds_focus(&list)).expect("Tab to the list"); + keys.press(gdk::Key::Tab, gdk::ModifierType::empty()).expect("Tab"); + wait_until(WAIT, on_copy).expect("Tab to the field's copy button"); + keys.press(gdk::Key::Tab, gdk::ModifierType::empty()).expect("Tab"); + wait_until(WAIT, || !crate::ui::a11y::holds_focus(&list)).expect("Tab out of the list"); +} diff --git a/linux/data/resources/ui/row-detail-pane.ui b/linux/data/resources/ui/row-detail-pane.ui index 133dfbeccd..85de2424b4 100644 --- a/linux/data/resources/ui/row-detail-pane.ui +++ b/linux/data/resources/ui/row-detail-pane.ui @@ -170,6 +170,10 @@ 120 + + item Fields From 78baf3d1adff456194dd9bfa5a1dc3108701f63d Mon Sep 17 00:00:00 2001 From: Ngo Quoc Dat Date: Tue, 10 Nov 2026 04:27:22 +0700 Subject: [PATCH 14/14] test(linux-grid): keep the row detail copy tests clear of other open edits --- .../app/src/ui/data_grid/row_detail/fields.rs | 3 +- .../app/src/ui/data_grid/row_detail/tests.rs | 144 +++++++++--------- 2 files changed, 73 insertions(+), 74 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 1fddc6bedd..954d4fcca9 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 @@ -9,7 +9,6 @@ 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::selection::Target; use crate::ui::data_grid::tracked_values::cell_description; use crate::ui::data_grid::{DataGrid, GridRow, ServerValue, TrackedValues}; use crate::ui::handler_guard::HandlerGuard; @@ -502,7 +501,7 @@ impl RowDetailPane { let (Some(grid), Some(row)) = (self.grid(), self.current_pin()) else { return; }; - grid.hold_menu_target(Target { + grid.hold_menu_target(crate::ui::data_grid::selection::Target { cell: Some((row.clone(), column)), rows: vec![row], }); 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 004dbe358c..c7597bc567 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 @@ -512,6 +512,78 @@ fn the_fields_follow_the_grid_column_order() { assert_eq!(fields(&pane), [1, 2, 0], "a hidden column's field did not go last"); } +fn copy_button(pane: &RowDetailPane, column: usize) -> gtk::Button { + let row = drawn_field(pane, column).child().expect("the field's row"); + descendants(&row) + .into_iter() + .filter_map(|widget| widget.downcast::().ok()) + .find(|button| button.icon_name().as_deref() == Some(crate::ui::icons::EDIT_COPY)) + .expect("the field's copy button") +} + +#[gtk4::test] +fn a_fields_copy_button_copies_its_whole_value_and_leaves_the_editor() { + let long = "x".repeat(DISPLAY_MAX_CHARS + 500); + let (grid, pane) = opened( + three_text_columns(), + vec![vec![Value::Int(1), Value::Text("A".into()), Value::Text(long.clone())]], + ); + grid.focus(0, 1); + drain_main_context(); + let heard: Rc>> = Rc::default(); + let log = heard.clone(); + grid.grid.connect_request(move |_, request| { + if let GridRequest::Toast(text) = request { + log.borrow_mut().push(text); + } + }); + + copy_button(&pane, 2).emit_clicked(); + wait_until(WAIT, || !heard.borrow().is_empty()).expect("the copy lands"); + + let clipboard = grid.grid.clipboard(); + let copied = finish_on_main(WAIT, async move { clipboard.read_text_future().await }) + .expect("the clipboard to answer") + .expect("text on the clipboard"); + assert_eq!( + copied.as_deref().map(str::len), + Some(long.len()), + "the copy took the text the field draws" + ); + assert_eq!(selected_field(&pane), Some(1), "the copy moved the editor"); + assert_eq!(pane.typed_text(), "A"); +} + +/// The arrows go from field to field, so Tab leaves the list once past +/// the focused field's own buttons rather than through every field. +#[gtk4::test] +fn tab_leaves_the_field_list_after_the_focused_field() { + 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 list = pane.imp().field_list.get(); + wait_until(WAIT, || { + pane.imp().field_search.is_mapped() && list.width() > 0 && list.height() > 0 + }) + .expect("the fields are laid out"); + crate::test_support::after_next_frame(&grid.window); + assert!(pane.imp().field_search.grab_focus()); + let keys = crate::test_support::KeyInjector::connect().expect("an X11 display"); + let on_copy = || { + gtk::prelude::GtkWindowExt::focus(&grid.window) + .and_downcast::() + .is_some_and(|button| button.icon_name().as_deref() == Some(crate::ui::icons::EDIT_COPY)) + }; + + keys.press(gdk::Key::Tab, gdk::ModifierType::empty()).expect("Tab"); + wait_until(WAIT, || crate::ui::a11y::holds_focus(&list)).expect("Tab to the list"); + keys.press(gdk::Key::Tab, gdk::ModifierType::empty()).expect("Tab"); + wait_until(WAIT, on_copy).expect("Tab to the field's copy button"); + keys.press(gdk::Key::Tab, gdk::ModifierType::empty()).expect("Tab"); + wait_until(WAIT, || !crate::ui::a11y::holds_focus(&list)).expect("Tab out of the list"); +} + #[gtk4::test] fn every_control_in_the_pane_is_named() { let (grid, pane) = opened(two_text_columns(), two_text_values()); @@ -1837,75 +1909,3 @@ fn search_keys_and_tab_order_reach_the_filter_list_and_value() { .expect("Escape"); wait_until(WAIT, || !grid.grid.imp().split_view.shows_sidebar()).expect("Escape closes the empty overlay search"); } - -fn copy_button(pane: &RowDetailPane, column: usize) -> gtk::Button { - let row = drawn_field(pane, column).child().expect("the field's row"); - descendants(&row) - .into_iter() - .filter_map(|widget| widget.downcast::().ok()) - .find(|button| button.icon_name().as_deref() == Some(crate::ui::icons::EDIT_COPY)) - .expect("the field's copy button") -} - -#[gtk4::test] -fn a_fields_copy_button_copies_its_whole_value_and_leaves_the_editor() { - let long = "x".repeat(DISPLAY_MAX_CHARS + 500); - let (grid, pane) = opened( - three_text_columns(), - vec![vec![Value::Int(1), Value::Text("A".into()), Value::Text(long.clone())]], - ); - grid.focus(0, 1); - drain_main_context(); - let heard: Rc>> = Rc::default(); - let log = heard.clone(); - grid.grid.connect_request(move |_, request| { - if let GridRequest::Toast(text) = request { - log.borrow_mut().push(text); - } - }); - - copy_button(&pane, 2).emit_clicked(); - wait_until(WAIT, || !heard.borrow().is_empty()).expect("the copy lands"); - - let clipboard = grid.grid.clipboard(); - let copied = finish_on_main(WAIT, async move { clipboard.read_text_future().await }) - .expect("the clipboard to answer") - .expect("text on the clipboard"); - assert_eq!( - copied.as_deref().map(str::len), - Some(long.len()), - "the copy took the text the field draws" - ); - assert_eq!(selected_field(&pane), Some(1), "the copy moved the editor"); - assert_eq!(pane.typed_text(), "A"); -} - -/// The arrows go from field to field, so Tab leaves the list once past -/// the focused field's own buttons rather than through every field. -#[gtk4::test] -fn tab_leaves_the_field_list_after_the_focused_field() { - 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 list = pane.imp().field_list.get(); - wait_until(WAIT, || { - pane.imp().field_search.is_mapped() && list.width() > 0 && list.height() > 0 - }) - .expect("the fields are laid out"); - crate::test_support::after_next_frame(&grid.window); - assert!(pane.imp().field_search.grab_focus()); - let keys = crate::test_support::KeyInjector::connect().expect("an X11 display"); - let on_copy = || { - gtk::prelude::GtkWindowExt::focus(&grid.window) - .and_downcast::() - .is_some_and(|button| button.icon_name().as_deref() == Some(crate::ui::icons::EDIT_COPY)) - }; - - keys.press(gdk::Key::Tab, gdk::ModifierType::empty()).expect("Tab"); - wait_until(WAIT, || crate::ui::a11y::holds_focus(&list)).expect("Tab to the list"); - keys.press(gdk::Key::Tab, gdk::ModifierType::empty()).expect("Tab"); - wait_until(WAIT, on_copy).expect("Tab to the field's copy button"); - keys.press(gdk::Key::Tab, gdk::ModifierType::empty()).expect("Tab"); - wait_until(WAIT, || !crate::ui::a11y::holds_focus(&list)).expect("Tab out of the list"); -}