From 9333baa16d6f8053db41e445f126864650ffa754 Mon Sep 17 00:00:00 2001 From: Guillem Hermida Date: Fri, 23 Oct 2026 16:15:47 +0200 Subject: [PATCH] ui: the Edit panel's back arrow, under All tools since main's new layout, leaves through enter_mode too --- crates/ui-egui/src/panels.rs | 2 +- crates/ui-egui/tests/it/editing.rs | 21 ++++++++++++++++----- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/crates/ui-egui/src/panels.rs b/crates/ui-egui/src/panels.rs index 6cecdbd79..13838ad9c 100644 --- a/crates/ui-egui/src/panels.rs +++ b/crates/ui-egui/src/panels.rs @@ -300,7 +300,7 @@ fn edit_panel(app: &mut PdfCraftApp, ui: &mut egui::Ui, t: &Tokens, g: &'static ui.horizontal(|ui| { if from_all_tools && icons::button(ui, "chevron-left", 26.0, false, tl!("Back to all tools")).clicked() { app.left = LeftPanel::AllTools; - app.mode = crate::Mode::AllTools; + app.enter_mode(crate::Mode::AllTools); } // "Edit" under the Edit tab, as Acrobat titles it; the tool's own name from All tools. let title = if from_all_tools { tl!(g.label) } else { tl!("Edit") }; diff --git a/crates/ui-egui/tests/it/editing.rs b/crates/ui-egui/tests/it/editing.rs index 751c5a248..4d00a6bfe 100644 --- a/crates/ui-egui/tests/it/editing.rs +++ b/crates/ui-egui/tests/it/editing.rs @@ -3284,6 +3284,12 @@ fn edit_tab_with_an_open_paragraph(h: &mut Harness<'static, PdfCraftApp>) { h.get_by_label("Edit").click(); h.run_steps(3); assert_eq!((h.state().mode, h.state().quick_tool), (Mode::Edit, QuickTool::EditText)); + open_the_first_line(h); +} + +/// With Edit text & images on, opens the line "Page 1" in the paragraph editor and retypes it as +/// "Chapter One", leaving the editor open. +fn open_the_first_line(h: &mut Harness<'static, PdfCraftApp>) { let r = h.state().views[0].page_screen_rect(0).expect("on screen"); let at = egui::pos2(r.left() + 40.0 / 200.0 * r.width(), r.top() + (300.0 - 158.0) / 300.0 * r.height()); h.hover_at(at); @@ -3321,14 +3327,19 @@ fn the_read_mode_command_applies_an_open_paragraph_and_puts_edit_text_down() { assert_edit_text_put_down_and_the_paragraph_applied(h.state()); } -/// The Edit panel's back arrow leaves Edit for All tools as the mode bar does: Edit text & images -/// is put down and a paragraph still open in the editor is applied, instead of every paragraph -/// keeping its box, and the editor staying open, under All tools. +/// The Edit panel's back arrow (it has one when opened from All tools; the Edit tab is its own way +/// back) leaves for All tools as the mode bar does: Edit text & images is put down and a paragraph +/// still open in the editor is applied, instead of every paragraph keeping its box, and the editor +/// staying open, under All tools. #[test] fn the_edit_panel_back_arrow_applies_an_open_paragraph_and_puts_edit_text_down() { - use pdfcraft_ui_egui::{LeftPanel, Mode}; + use pdfcraft_ui_egui::{LeftPanel, Mode, QuickTool}; let mut h = harness(1, |_| {}); - edit_tab_with_an_open_paragraph(&mut h); + // All tools ▸ Edit a PDF ▸ Edit text & images: the Edit panel, under All tools. + assert!(h.state_mut().execute("edit.edit_text")); + h.run_steps(3); + assert_eq!((h.state().mode, h.state().quick_tool), (Mode::AllTools, QuickTool::EditText)); + open_the_first_line(&mut h); h.get_by_label("Back to all tools").click(); h.run_steps(3); assert_eq!((h.state().mode, h.state().left), (Mode::AllTools, LeftPanel::AllTools));