From 8f8078c134c4f964e9b54d14480794ea2aae9a6a Mon Sep 17 00:00:00 2001 From: FredApps <153173854+FredApps@users.noreply.github.com> Date: Wed, 18 Nov 2026 19:50:37 +0700 Subject: [PATCH] Fix main's build and tests after the recent merges (#4474) - Import SheetApp in the pivot pane tests. - Move the keyboard owner check out of keyboard() to stay within the complexity limit. - Aim the title bar button helper at the button's own node. Fixes #4473. Signed-off-by: FredApps <153173854+FredApps@users.noreply.github.com> --- crates/ui-egui/src/grid/keyboard.rs | 14 ++++++++++---- crates/ui-egui/tests/it/file_menu.rs | 6 ++++-- crates/ui-egui/tests/it/pivot_pane.rs | 2 +- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/crates/ui-egui/src/grid/keyboard.rs b/crates/ui-egui/src/grid/keyboard.rs index afecce502..89259ca86 100644 --- a/crates/ui-egui/src/grid/keyboard.rs +++ b/crates/ui-egui/src/grid/keyboard.rs @@ -2,8 +2,10 @@ use super::geo::Geo; use super::menus::is_checkbox; use super::{CellRef, Drag, Sheet, SheetApp, json}; -/// Grid keyboard handling when no text field has focus. -pub(super) fn keyboard(app: &mut SheetApp, ctx: &egui::Context, resp: &egui::Response, geo: &Geo, sh: &Sheet) { +/// Whether something other than the grid owns the keyboard this frame: an editor, a dialog, a +/// message, a menu or another focused widget. Kept out of [`keyboard`] to hold its complexity +/// within the workspace limit. +fn keyboard_elsewhere(app: &SheetApp, ctx: &egui::Context, resp: &egui::Response) -> bool { // Focus left on an editor that no longer exists goes back to the grid. let stale = [egui::Id::unique("gridcraft.cell_editor"), egui::Id::unique("gridcraft.formula_bar"), crate::text_box::editor_id()]; let editing = app.editor.is_some() || app.text_box_editor.is_some(); @@ -14,7 +16,7 @@ pub(super) fn keyboard(app: &mut SheetApp, ctx: &egui::Context, resp: &egui::Res // An open filter menu owns the keyboard even when a click inside it left focus on nothing (#1516). // So do the fill menu (its Esc closes it, not the copy) and the right-drag that opens it (an // arrow key would move the selection the menu fills from), and a macro's question. - if editing + editing || app.dialog.is_some() || other_focus || app.message.is_some() @@ -22,7 +24,11 @@ pub(super) fn keyboard(app: &mut SheetApp, ctx: &egui::Context, resp: &egui::Res || app.grid.fill_menu.is_some() || matches!(app.grid.drag, Drag::Fill { menu: true, .. }) || app.macros.question.is_some() - { +} + +/// Grid keyboard handling when no text field has focus. +pub(super) fn keyboard(app: &mut SheetApp, ctx: &egui::Context, resp: &egui::Response, geo: &Geo, sh: &Sheet) { + if keyboard_elsewhere(app, ctx, resp) { return; } if ctx.memory(|m| m.focused()).is_none() { diff --git a/crates/ui-egui/tests/it/file_menu.rs b/crates/ui-egui/tests/it/file_menu.rs index 0bde33944..4ec8aab60 100644 --- a/crates/ui-egui/tests/it/file_menu.rs +++ b/crates/ui-egui/tests/it/file_menu.rs @@ -176,8 +176,10 @@ fn title_bar_button(h: &mut egui_kittest::Harness<'static, SheetApp>, name: &str let at = egui::pos2(x, autosave.center().y); h.hover_at(at); h.run_steps(3); - if h.query_by_label_contains(&tip).is_some() { - return at; + // The button's accessible label carries its tooltip, so the node found may be the button + // itself rather than a tooltip at the pointer: aim at the node. + if let Some(node) = h.query_by_label_contains(&tip) { + return node.rect().center(); } x += 6.0; } diff --git a/crates/ui-egui/tests/it/pivot_pane.rs b/crates/ui-egui/tests/it/pivot_pane.rs index 0ac619d3a..1076e3e14 100644 --- a/crates/ui-egui/tests/it/pivot_pane.rs +++ b/crates/ui-egui/tests/it/pivot_pane.rs @@ -2,7 +2,7 @@ use egui::{Color32, RawInput, Rect, Shape, pos2, vec2}; use gridcraft_engine::Session; -use gridcraft_ui_egui::theme; +use gridcraft_ui_egui::{SheetApp, theme}; use serde_json::json; /// Builds a pivot report at D3 and returns the painted shapes after six frames in the caller's light or dark mode.