Compare commits

..
Author SHA1 Message Date
MaciekandMaciej Malinowski 42acfafcd3 Find and Replace: Undo and Redo reach the sheet while the dialog is open (#2140)
* Find and Replace: Undo and Redo reach the sheet while the dialog is open

Ctrl+Z after Replace All did nothing until the dialog was closed: the open
dialog kept the keyboard from the grid. The dialog now undoes and redoes
the workbook itself unless a text box has focus (there the shortcuts edit
the typed text).

* Find and Replace: Undo and Redo use the sheet's shortcut table

The dialog passed hard-coded keys to edit.undo and edit.redo. It now hands
Cmd/Ctrl+Z, Cmd/Ctrl+Shift+Z and Cmd/Ctrl+Y to ribbon::shortcut, the table
the grid uses, so the dialog and the sheet keep the same bindings. The test
also covers the Mac Redo shortcut (Cmd+Shift+Z).

* fix(find): allow workbook undo when a dialog button has focus

Reserve Undo/Redo for text editing only while a text edit has focus. The regression reproduces the failure with keyboard focus on Replace All, checks both Redo shortcuts, and verifies text-field Undo leaves the sheet unchanged. Regression failed before the fix and passes now. Validation: 1143 UI integration tests pass; only existing missing-glyph failures U+1E9E and U+1EBB remain. WASM, assets, layers and generators pass. Full CI reaches the unchanged Windows CLI clippy::only_used_in_recursion failure in apps/gridcraft-cli/src/check.rs.

* fix(find): block workbook shortcuts behind a modal message

Check app.message before dispatching workbook Undo/Redo. Regression uses an empty Replace All search to open the real error, covers all three shortcuts, and checks Redo after dismissal. Extend text-focus coverage to type and undo actual text. Modal regression fails before the guard and passes after it. Validation: 1144 integration tests pass; two existing missing-glyph failures remain. WASM, assets and layers pass. Full CI still stops at the unchanged Windows CLI clippy::only_used_in_recursion warning.

---------

Co-authored-by: Maciej Malinowski <231036771+webglobecontact-ui@users.noreply.github.com>
2026-11-19 08:37:18 +07:00
8 changed files with 97 additions and 53 deletions
Generated
+6 -38
View File
@@ -919,11 +919,6 @@ dependencies = [
"libc",
]
[[package]]
name = "craft-cfb"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=3b8e426a260695af840a2cd79a064d40778f939e#3b8e426a260695af840a2cd79a064d40778f939e"
[[package]]
name = "craft-cfb"
version = "0.1.0"
@@ -937,17 +932,6 @@ dependencies = [
"thiserror 2.0.21",
]
[[package]]
name = "craft-drawingml"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=3b8e426a260695af840a2cd79a064d40778f939e#3b8e426a260695af840a2cd79a064d40778f939e"
dependencies = [
"craft-xml 0.1.0 (git+https://github.com/storytold/craft-libs?rev=3b8e426a260695af840a2cd79a064d40778f939e)",
"kurbo",
"log",
"serde",
]
[[package]]
name = "craft-drawingml"
version = "0.1.0"
@@ -1033,7 +1017,7 @@ source = "git+https://github.com/storytold/craft-libs?rev=e98299546f5c5c3c22388d
dependencies = [
"aes",
"base64 0.23.1",
"craft-cfb 0.1.0 (git+https://github.com/storytold/craft-libs?rev=e98299546f5c5c3c22388d16507f8b5e61a5f280)",
"craft-cfb",
"craft-xml 0.1.0 (git+https://github.com/storytold/craft-libs?rev=e98299546f5c5c3c22388d16507f8b5e61a5f280)",
"getrandom 0.3.4",
"hmac",
@@ -1078,11 +1062,6 @@ name = "craft-sheet"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=010702ee9b030844c852939095b1da0d0656a890#010702ee9b030844c852939095b1da0d0656a890"
[[package]]
name = "craft-sheet"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=3b8e426a260695af840a2cd79a064d40778f939e#3b8e426a260695af840a2cd79a064d40778f939e"
[[package]]
name = "craft-sheet"
version = "0.1.0"
@@ -1188,10 +1167,10 @@ dependencies = [
[[package]]
name = "craft-xls"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=3b8e426a260695af840a2cd79a064d40778f939e#3b8e426a260695af840a2cd79a064d40778f939e"
source = "git+https://github.com/storytold/craft-libs?rev=e98299546f5c5c3c22388d16507f8b5e61a5f280#e98299546f5c5c3c22388d16507f8b5e61a5f280"
dependencies = [
"craft-cfb 0.1.0 (git+https://github.com/storytold/craft-libs?rev=3b8e426a260695af840a2cd79a064d40778f939e)",
"craft-sheet 0.1.0 (git+https://github.com/storytold/craft-libs?rev=3b8e426a260695af840a2cd79a064d40778f939e)",
"craft-cfb",
"craft-sheet 0.1.0 (git+https://github.com/storytold/craft-libs?rev=e98299546f5c5c3c22388d16507f8b5e61a5f280)",
"md-5",
"miniz_oxide 0.9.1",
"sha1 0.10.7",
@@ -1203,7 +1182,7 @@ name = "craft-xlsx"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=e98299546f5c5c3c22388d16507f8b5e61a5f280#e98299546f5c5c3c22388d16507f8b5e61a5f280"
dependencies = [
"craft-drawingml 0.1.0 (git+https://github.com/storytold/craft-libs?rev=e98299546f5c5c3c22388d16507f8b5e61a5f280)",
"craft-drawingml",
"craft-opc",
"craft-sheet 0.1.0 (git+https://github.com/storytold/craft-libs?rev=e98299546f5c5c3c22388d16507f8b5e61a5f280)",
"craft-xml 0.1.0 (git+https://github.com/storytold/craft-libs?rev=e98299546f5c5c3c22388d16507f8b5e61a5f280)",
@@ -1220,16 +1199,6 @@ dependencies = [
"thiserror 2.0.21",
]
[[package]]
name = "craft-xml"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=3b8e426a260695af840a2cd79a064d40778f939e#3b8e426a260695af840a2cd79a064d40778f939e"
dependencies = [
"quick-xml 0.41.0",
"serde",
"thiserror 2.0.21",
]
[[package]]
name = "craft-xml"
version = "0.1.0"
@@ -2488,9 +2457,8 @@ dependencies = [
name = "gridcraft-xlsx"
version = "0.19.1"
dependencies = [
"craft-cfb 0.1.0 (git+https://github.com/storytold/craft-libs?rev=e98299546f5c5c3c22388d16507f8b5e61a5f280)",
"craft-cfb",
"craft-csv",
"craft-drawingml 0.1.0 (git+https://github.com/storytold/craft-libs?rev=3b8e426a260695af840a2cd79a064d40778f939e)",
"craft-ods",
"craft-offcrypto",
"craft-opc",
+1 -2
View File
@@ -49,8 +49,7 @@ craft-gridcraft-format = { git = "https://github.com/storytold/craft-libs", rev
# SpreadsheetML string encoding/decoding; workbook model mapping stays in gridcraft-xlsx.
craft-xlsx = { git = "https://github.com/storytold/craft-libs", rev = "e98299546f5c5c3c22388d16507f8b5e61a5f280", version = "0.1.0" }
craft-xml = { git = "https://github.com/storytold/craft-libs", rev = "e98299546f5c5c3c22388d16507f8b5e61a5f280", version = "0.1.0" }
craft-xls = { git = "https://github.com/storytold/craft-libs", rev = "3b8e426a260695af840a2cd79a064d40778f939e", version = "0.1.0" }
craft-drawingml = { git = "https://github.com/storytold/craft-libs", rev = "3b8e426a260695af840a2cd79a064d40778f939e", version = "0.1.0" }
craft-xls = { git = "https://github.com/storytold/craft-libs", rev = "e98299546f5c5c3c22388d16507f8b5e61a5f280", version = "0.1.0" }
# foundation
thiserror = "2"
+15
View File
@@ -1,8 +1,23 @@
use egui::Modifiers;
use super::show::ok_cancel;
use super::{Dialog, Json, Key, SheetApp, json};
/// Draws the Find/Replace form with case, whole-cell and workbook options, requests field focus once, and runs find/replace with the current parameters.
pub(super) fn find(app: &mut SheetApp, ui: &mut egui::Ui, d: &mut Dialog) {
// The dialog stays open over the sheet, so Undo and Redo reach the workbook (a Replace All
// is undone without closing it first); inside a text box they edit the typed text instead.
// A modal message blocks workbook shortcuts; otherwise use the grid's own shortcut table.
if app.message.is_none() && !ui.ctx().text_edit_focused() {
let pressed = ui.input_mut(|i| {
[(Modifiers::COMMAND | Modifiers::SHIFT, Key::Z), (Modifiers::COMMAND, Key::Z), (Modifiers::COMMAND, Key::Y)]
.into_iter()
.find(|&(m, key)| i.consume_key(m, key))
});
if let Some((m, key)) = pressed {
crate::ribbon::shortcut(app, key, m);
}
}
ui.horizontal(|ui| {
for tab in ["Find", "Replace"] {
if ui.selectable_label(d.tab == tab, tab).clicked() {
+71
View File
@@ -336,6 +336,77 @@ fn arrows_escape_and_undo() {
assert_eq!(value(&h, "B2"), Value::Empty);
}
#[test]
fn undo_and_redo_reach_the_sheet_while_find_and_replace_is_open() {
let mut h = harness(blank());
for t in ["x1", "x2"] {
text(&mut h, t);
key(&mut h, Key::Enter, Modifiers::NONE);
}
h.state_mut().open_dialog("find", json!({"replace": true}));
h.run_steps(3);
if let Some(d) = h.state_mut().dialog.as_mut() {
d.values.insert("what".into(), json!("x"));
d.values.insert("with".into(), json!("y"));
}
h.run_steps(2);
h.get_by_label("Replace All").click();
h.run_steps(3);
assert_eq!((value(&h, "A1"), value(&h, "A2")), (Value::from("y1"), Value::from("y2")));
// Keyboard focus on a button must not reserve Undo/Redo for text editing.
h.get_by_label("Replace All").focus();
h.run_steps(2);
assert!(h.ctx.egui_wants_keyboard_input());
assert!(!h.ctx.text_edit_focused());
key(&mut h, Key::Z, Modifiers::COMMAND);
assert!(h.state().dialog.is_some(), "the dialog stays open");
assert_eq!((value(&h, "A1"), value(&h, "A2")), (Value::from("x1"), Value::from("x2")), "one Undo takes back the whole Replace All");
key(&mut h, Key::Y, Modifiers::COMMAND);
assert_eq!((value(&h, "A1"), value(&h, "A2")), (Value::from("y1"), Value::from("y2")));
// The Mac Redo shortcut works too, as it does on the sheet.
key(&mut h, Key::Z, Modifiers::COMMAND);
assert_eq!(value(&h, "A1"), Value::from("x1"));
key(&mut h, Key::Z, Modifiers::COMMAND | Modifiers::SHIFT);
assert_eq!((value(&h, "A1"), value(&h, "A2")), (Value::from("y1"), Value::from("y2")));
assert!(h.state().dialog.is_some(), "the dialog is still open");
h.get_by_label("Find what:").focus();
h.run_steps(2);
assert!(h.ctx.text_edit_focused());
let before = h.state().dialog.as_ref().unwrap().values.get("what").cloned();
h.input_mut().events.push(Event::Text("extra".into()));
h.run_steps(2);
assert_ne!(h.state().dialog.as_ref().unwrap().values.get("what"), before.as_ref());
key(&mut h, Key::Z, Modifiers::COMMAND);
assert_eq!(h.state().dialog.as_ref().unwrap().values.get("what"), before.as_ref(), "Undo restores the Find field");
assert_eq!((value(&h, "A1"), value(&h, "A2")), (Value::from("y1"), Value::from("y2")), "text-field Undo leaves the sheet alone");
}
#[test]
fn find_message_blocks_workbook_undo_and_redo() {
let mut session = blank();
session.execute("cell.set", json!({"cell": "A1", "input": "first"})).unwrap();
session.execute("cell.set", json!({"cell": "A1", "input": "second"})).unwrap();
session.execute("edit.undo", json!({})).unwrap();
let mut h = harness(session);
h.state_mut().open_dialog("find", json!({"replace": true}));
h.run_steps(3);
// An empty search raises the real modal error over Find and Replace.
h.get_by_label("Replace All").click();
h.run_steps(3);
assert!(h.state().message.is_some());
assert!(!h.ctx.text_edit_focused());
for (key_code, modifiers) in [(Key::Z, Modifiers::COMMAND), (Key::Y, Modifiers::COMMAND), (Key::Z, Modifiers::COMMAND | Modifiers::SHIFT)] {
key(&mut h, key_code, modifiers);
assert_eq!(value(&h, "A1"), Value::from("first"), "the message blocks workbook shortcuts");
assert!(h.state().message.is_some());
}
h.state_mut().message = None;
h.run_steps(2);
h.get_by_label("Replace All").focus();
h.run_steps(2);
key(&mut h, Key::Y, Modifiers::COMMAND);
assert_eq!(value(&h, "A1"), Value::from("second"), "Redo works again after dismissing the message");
}
#[test]
fn shift_arrows_in_point_mode_extend_from_the_pointed_cell() {
let mut s = blank();
-1
View File
@@ -20,7 +20,6 @@ gridcraft-math = { workspace = true }
gridcraft-model = { workspace = true }
craft-cfb = { workspace = true }
craft-csv = { workspace = true }
craft-drawingml = { workspace = true }
craft-ods = { workspace = true }
craft-offcrypto = { workspace = true }
craft-opc = { workspace = true }
+1 -10
View File
@@ -20,16 +20,7 @@ pub const REL_COLORS: &str = "http://schemas.microsoft.com/office/2011/relations
/// Kinds written as chartex parts.
pub fn is_chartex(k: ChartKind) -> bool {
use craft_drawingml::chart::ChartType;
match k {
ChartKind::Histogram => ChartType::Histogram.is_chartex(),
ChartKind::BoxWhisker => ChartType::BoxWhisker.is_chartex(),
ChartKind::Waterfall => ChartType::Waterfall.is_chartex(),
ChartKind::Funnel => ChartType::Funnel.is_chartex(),
ChartKind::Treemap => ChartType::Treemap.is_chartex(),
ChartKind::Sunburst => ChartType::Sunburst.is_chartex(),
_ => false,
}
matches!(k, ChartKind::Histogram | ChartKind::BoxWhisker | ChartKind::Waterfall | ChartKind::Funnel | ChartKind::Treemap | ChartKind::Sunburst)
}
/// The `mc:Choice` requirement for a kind's drawing frame: (prefix, namespace). Funnel charts
+1 -1
View File
@@ -227,7 +227,7 @@ fn read_shape(obj: &El, anchor: Anchor) -> Option<Shape> {
// shape (an ellipse, a filled rectangle) it, like any other warp, leaves the shape what its
// geometry says.
let word_art = prst == "rect"
&& (tx_box || (sp.child("noFill").is_some() && ln.is_none_or(|l| l.child("solidFill").is_none())))
&& (tx_box || (sp.child("noFill").is_some() && !ln.is_some_and(|l| l.child("solidFill").is_some())))
&& obj.path(&["txBody", "bodyPr", "prstTxWarp"]).is_some_and(|w| w.attr("prst") == Some("textNoShape"));
let kind = match prst {
_ if word_art => ShapeKind::WordArt,
+2 -1
View File
@@ -1,6 +1,6 @@
# UI parity
> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-11-05 · **Change:** minor (punctuation shortcuts follow the keyboard layout's characters; earlier: preserve centered emoji and symbol fallback placement; earlier: preserve leading and trailing blank cell lines; earlier: align wrapped and unwrapped cells; earlier: CJK title baseline regression and mixed-script rendering validation; earlier: form controls: buttons, sliders and spin buttons on the sheet; earlier: Highlight the active cell's row, a global preference in File › Options › General; earlier: a linked cell's menu edits, opens or removes the link; earlier: Display options for this workbook: sheet tabs and scroll bars; earlier: dragging over row or column headers in point mode extends the reference; earlier: a picture on the system clipboard pastes as a floating picture at the active cell with Cmd/Ctrl+V or Paste (#699); earlier: frozen columns keep their text, gridlines and merged borders whole while the sheet scrolls (#2544); earlier: every Paste Special option has its access key; earlier: the Draw tab's live stroke preview uses the pen's colour and thickness; earlier: copy quotes only cells with a tab or line break, as Excel does; earlier: Ctrl+. Next Corner of Selection; earlier: dragging the selection's border onto data asks before replacing it; earlier: RefEdit reference boxes in dialogs: Goal Seek, Solver and Data Analysis use them, the arrow keys select while a dialog is collapsed and F4 cycles a reference's anchors; earlier: Python cells: Python mode in the formula bar; earlier: Insert › Equation and the equation editor; earlier: every floating object selects, resizes from eight handles and deletes with the keyboard; earlier: Formulas › Error Checking › Trace Error; trace arrows stay through a zoom (#3097); earlier: Page Setup sets the page order, Down, then over or Over, then down, which printing, the print preview, Page Break Preview and Page Layout view follow; earlier: Formulas › Function Library as labelled buttons with category menus; Recently Used and the Insert Function categories; Esc leaves a File-page text field before closing the view; earlier: checkbox cells print as boxes; Ctrl+arrow and Ctrl+Shift+arrow while pointing a formula reference; editing a hyperlink loads its existing fields; AutoSum over a selected row puts its total to the right; ribbon catalog count 276 / 292) · **Target:** Microsoft Excel (Microsoft 365), Excel for Mac 16.113.4
> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-11-05 · **Change:** minor (Find and Replace keeps workbook Undo/Redo available while a button has keyboard focus; text fields keep their own Undo; earlier: punctuation shortcuts follow the keyboard layout's characters; earlier: preserve centered emoji and symbol fallback placement; earlier: preserve leading and trailing blank cell lines; earlier: align wrapped and unwrapped cells; earlier: CJK title baseline regression and mixed-script rendering validation; earlier: form controls: buttons, sliders and spin buttons on the sheet; earlier: Highlight the active cell's row, a global preference in File › Options › General; earlier: a linked cell's menu edits, opens or removes the link; earlier: Display options for this workbook: sheet tabs and scroll bars; earlier: dragging over row or column headers in point mode extends the reference; earlier: a picture on the system clipboard pastes as a floating picture at the active cell with Cmd/Ctrl+V or Paste (#699); earlier: frozen columns keep their text, gridlines and merged borders whole while the sheet scrolls (#2544); earlier: every Paste Special option has its access key; earlier: the Draw tab's live stroke preview uses the pen's colour and thickness; earlier: copy quotes only cells with a tab or line break, as Excel does; earlier: Ctrl+. Next Corner of Selection; earlier: dragging the selection's border onto data asks before replacing it; earlier: RefEdit reference boxes in dialogs: Goal Seek, Solver and Data Analysis use them, the arrow keys select while a dialog is collapsed and F4 cycles a reference's anchors; earlier: Python cells: Python mode in the formula bar; earlier: Insert › Equation and the equation editor; earlier: every floating object selects, resizes from eight handles and deletes with the keyboard; earlier: Formulas › Error Checking › Trace Error; trace arrows stay through a zoom (#3097); earlier: Page Setup sets the page order, Down, then over or Over, then down, which printing, the print preview, Page Break Preview and Page Layout view follow; earlier: Formulas › Function Library as labelled buttons with category menus; Recently Used and the Insert Function categories; Esc leaves a File-page text field before closing the view; earlier: checkbox cells print as boxes; Ctrl+arrow and Ctrl+Shift+arrow while pointing a formula reference; editing a hyperlink loads its existing fields; AutoSum over a selected row puts its total to the right; ribbon catalog count 276 / 292) · **Target:** Microsoft Excel (Microsoft 365), Excel for Mac 16.113.4
Interaction, controls and feel, against Excel. Part of [target-app-parity.md](target-app-parity.md).
**UI/UX fidelity: ~55% ready, 50–80 h** (estimated). Ribbon command coverage is measured
@@ -275,6 +275,7 @@ scrollbar bugs 2–4 · pixel/feel pass against observed Excel 7–12.
| 2026-11-04 | minor | Preserve leading and trailing blank lines in wrapped cells when calculating vertical alignment; regression covers single, multiple and all-empty lines |
| 2026-11-04 | minor | Align wrapped and unwrapped cells with the same vertical margins; regressions compare numbers with mixed CJK/Latin text, including explicit line breaks |
| 2026-11-02 | minor | Form controls: buttons, sliders (scroll bars) and spin buttons placed, worked, selected and edited on the sheet (Insert › Controls, Assign Action, Format Control); catalog 281 / 296 |
| 2026-11-03 | minor | Find and Replace: workbook Undo/Redo works with a keyboard-focused button; focused text fields keep text-editing Undo, and a modal message blocks workbook shortcuts. Regression covers Replace All, both Redo shortcuts, actual text undo, and an error message |
| 2026-11-03 | minor | Highlight the active cell's row: a global preference that tints the whole row, off by default |
| 2026-11-03 | minor | The formula bar's bottom edge is a resize handle: dragging it sets the bar's height in whole lines, up to half the window, and dragging it to one line collapses it; expanding (the chevron, Ctrl+Shift+U) returns to the dragged height, which is kept with the UI preferences. `view.expandFormulaBar {lines}` sets it (#1246) |
| 2026-11-03 | minor | Cell context menu on a cell with a link: Edit Hyperlink… (the link dialog, titled Edit Hyperlink and filled with the link), Open Hyperlink and Remove Hyperlink, as in Excel, instead of Link… (#2120) |