diff --git a/crates/ui-egui/src/chrome/tabs.rs b/crates/ui-egui/src/chrome/tabs.rs index 0fbfa24fd4..4ba5c01293 100644 --- a/crates/ui-egui/src/chrome/tabs.rs +++ b/crates/ui-egui/src/chrome/tabs.rs @@ -224,11 +224,30 @@ pub fn isolation_bar(app: &mut VectorcraftApp, ui: &mut Ui, area: egui::Rect) { crumbs.push((None, false, pn.clone())); } // Up one level: the isolated object's parent group, or `object.exitIsolation`, which goes from an - // isolated sublayer to its parent layer and otherwise leaves isolation mode. - let up = match ancestry.iter().rev().nth(1).filter(|p| st.doc.node(**p).is_some_and(|n| !n.is_layer())) { + // isolated sublayer to its parent layer, from a group in a symbol's art to the symbol's layer, and + // otherwise leaves isolation mode. While a pattern is edited the back arrow is Done. Screen readers + // call it by what it does. + let parent_group = ancestry.iter().rev().nth(1).copied().filter(|p| st.doc.node(*p).is_some_and(|n| !n.is_layer())); + let up = match parent_group { Some(parent) => ("object.isolate", json!({ "id": parent.0 })), None => ("object.exitIsolation", json!({})), }; + let symbol_layer = st.doc.symbol_edit.as_ref().map(|e| e.layer); + let up_one = parent_group.is_some() + || symbol_layer.is_some_and(|l| l != iso && ancestry.contains(&l)) + || (st.doc.mask_edit.is_none() + && symbol_layer.is_none() + && st.doc.node(iso).is_some_and(|n| n.is_layer()) + && st.doc.parent_of(iso).is_some_and(|p| st.doc.is_editable(p))); + let back_name = if pattern_edit.is_some() { + tl!("Done") + } else if up_one { + tl!("Back One Level") + } else if symbol_layer == Some(iso) { + tl!("Exit Symbol Editing Mode") + } else { + tl!("Exit Isolation Mode") + }; let entries: Vec> = crumbs.iter().enumerate().map(|(i, (_, _, name))| Entry::new(i, name.clone())).collect(); let mut nav: Option<(&str, serde_json::Value)> = None; let mut pattern_cmd: Option<&str> = None; @@ -237,7 +256,7 @@ pub fn isolation_bar(app: &mut VectorcraftApp, ui: &mut Ui, area: egui::Rect) { let mut bar_ui = ui.new_child(egui::UiBuilder::new().max_rect(area)); Bar::new(tl!("Isolation mode"), BarKind::Options).show(&mut bar_ui, |ui, _| { Row::new().fill().senses_surface().show(ui, |ui, cx| { - if IconButton::new(craft::behavior::IconId::new("chevron_left")).label(tl!("Back")).show(ui).clicked() { + if IconButton::new(craft::behavior::IconId::new("chevron_left")).label(back_name).show(ui).clicked() { if pattern_edit.is_some() { pattern_cmd = Some("object.pattern.done"); } else { diff --git a/crates/ui-egui/src/chrome/tests.rs b/crates/ui-egui/src/chrome/tests.rs index 0d8ef2d500..6484290054 100644 --- a/crates/ui-egui/src/chrome/tests.rs +++ b/crates/ui-egui/src/chrome/tests.rs @@ -1277,9 +1277,28 @@ fn isolation_shown(app: crate::VectorcraftApp) -> Shown { /// A point on the isolation bar's own surface: right of its crumbs, at the end of the path, which fills the bar up /// to the pattern editing buttons at its right. fn isolation_bar_surface(bar: &mut Shown) -> egui::Pos2 { - let back = bar.named("Back"); let path = bar.named("Isolation path"); - egui::pos2(path.rect.right() - 8.0, back.center().y) + egui::pos2(path.rect.right() - 8.0, path.center().y) +} + +/// The names of the isolation bar's controls in the latest frame that screen readers read with `role`, sorted. +fn isolation_names(bar: &Shown, role: Role) -> Vec { + let tree = bar.tree(); + let mut names: Vec = + tree.keys().into_iter().filter(|key| tree.role_of(*key) == Some(role)).filter_map(|key| tree.name_of(key)).map(str::to_owned).collect(); + names.sort(); + names +} + +/// The isolation bar's back arrow: the leftmost button named `name`. +fn isolation_back(bar: &mut Shown, name: &str) -> Target { + bar.frame(Vec::new()); + let tree = bar.tree(); + let keys: Vec<_> = tree.keys().into_iter().filter(|key| tree.role_of(*key) == Some(Role::BUTTON) && tree.name_of(*key) == Some(name)).collect(); + keys.into_iter() + .filter_map(|key| bar.fixture.target(key)) + .min_by(|a, b| a.rect.left().total_cmp(&b.rect.left())) + .unwrap_or_else(|| panic!("no {name:?} button in {:?}", bar.names())) } /// #4468: In nested isolation, clicking the back button steps up one level in the hierarchy, @@ -1308,15 +1327,15 @@ fn isolation_bar_navigation_and_back_button_steps_up() { let isolation = |bar: &Shown| bar.app().session.active().unwrap().isolation; // Clicking back from `a` steps up to parent group `g1` - bar.click("Back"); + bar.click("Back One Level"); assert_eq!(isolation(&bar), Some(NodeId(g1))); // Clicking back from `g1` steps up to grandparent group `g2` - bar.click("Back"); + bar.click("Back One Level"); assert_eq!(isolation(&bar), Some(NodeId(g2))); // Clicking back from `g2` (parent is layer) exits isolation mode completely - bar.click("Back"); + bar.click("Exit Isolation Mode"); assert_eq!(isolation(&bar), None); // Deep isolate again to test clicking ancestor breadcrumb directly @@ -1355,11 +1374,11 @@ fn isolation_bar_back_button_steps_up_through_sublayers() { let steps = |bar: &Shown| bar.app().session.doc().unwrap().history.undo.len(); let before = steps(&bar); - bar.click("Back"); + bar.click("Back One Level"); assert_eq!(isolation(&bar), Some(mid), "back from the deepest sublayer"); - bar.click("Back"); + bar.click("Back One Level"); assert_eq!(isolation(&bar), Some(top), "back from the middle sublayer"); - bar.click("Back"); + bar.click("Exit Isolation Mode"); assert_eq!(isolation(&bar), None, "back from the top-level layer"); assert_eq!(steps(&bar), before, "no undo step"); @@ -1422,7 +1441,8 @@ fn isolation_bar_background_click_leaves_pattern_edit_open() { let st = app.session.active().unwrap(); assert!(st.doc.pattern_edit.is_some() && st.isolation.is_some(), "pattern editing stays open"); } - bar.click("Back"); + let back = isolation_back(&mut bar, "Done"); + bar.click_on(&back); let app = bar.app(); let st = app.session.active().unwrap(); assert!(st.doc.pattern_edit.is_none() && st.isolation.is_none(), "the back arrow ends pattern editing"); @@ -1506,6 +1526,72 @@ fn isolation_bar_click_on_the_current_name_exits() { assert_eq!(bar.app().session.active().unwrap().isolation, None); } +/// Screen readers call the isolation bar's back arrow by what it does: Back One Level, Exit Isolation Mode, Exit +/// Symbol Editing Mode, or Done while a pattern is edited, in the UI's language. Each crumb of the levels above is +/// a link with the name it shows, and the current object's name is not a control. +#[test] +fn the_isolation_bars_controls_have_screen_reader_names() { + use vectorcraft_doc::NodeId; + let mut app = crate::VectorcraftApp::new(Session::new(), Default::default()); + app.run("file.new", json!({"width": 400, "height": 200})).unwrap(); + let rect = |app: &mut crate::VectorcraftApp, x: f64| { + app.run("shape.rectangle", json!({"x": x, "y": 10, "width": 30, "height": 20})).unwrap()["id"].as_u64().unwrap() + }; + let (a, b) = (rect(&mut app, 10.0), rect(&mut app, 50.0)); + app.run("select.set", json!({"ids": [a, b]})).unwrap(); + app.run("object.group", json!({})).unwrap(); + let name = |app: &crate::VectorcraftApp, id: NodeId| app.session.active().unwrap().doc.node(id).unwrap().display_name(); + let st = app.session.active().unwrap(); + let (layer, group) = (st.doc.layer_of(NodeId(a)).unwrap(), st.doc.parent_of(NodeId(a)).unwrap()); + let (layer_name, group_name) = (name(&app, layer), name(&app, group)); + let mut bar = isolation_shown(app); + let shown = |bar: &mut Shown, role: Role| { + bar.frame(Vec::new()); + isolation_names(bar, role) + }; + + // A path in a group: back goes to the group. + bar.app().run("object.isolate", json!({"id": a})).unwrap(); + assert_eq!(shown(&mut bar, Role::BUTTON), ["Back One Level"]); + let mut crumbs = vec![layer_name.clone(), group_name.clone()]; + crumbs.sort(); + assert_eq!(shown(&mut bar, Role::LINK), crumbs, "the current object's name is not a link"); + + // The group itself: back leaves isolation mode. + bar.app().run("object.isolate", json!({"id": group.0})).unwrap(); + assert_eq!(shown(&mut bar, Role::BUTTON), ["Exit Isolation Mode"]); + assert_eq!(shown(&mut bar, Role::LINK), std::slice::from_ref(&layer_name)); + + // An isolated sublayer: back goes to its parent layer, and from the top-level layer it leaves. + let sub = bar.app().run("layer.newSublayer", json!({"parent": layer.0, "name": "Sublayer B"})).unwrap()["id"].as_u64().unwrap(); + bar.app().run("object.isolate", json!({"id": sub})).unwrap(); + assert_eq!(shown(&mut bar, Role::BUTTON), ["Back One Level"]); + bar.app().run("object.isolate", json!({"id": layer.0})).unwrap(); + assert_eq!(shown(&mut bar, Role::BUTTON), ["Exit Isolation Mode"]); + bar.app().run("object.isolate", json!({"id": group.0})).unwrap(); + + // In German. + crate::i18n::set_current(crate::i18n::Lang::from_code("de").expect("de registered")); + let german = shown(&mut bar, Role::BUTTON); + crate::i18n::set_current(crate::i18n::Lang::EN); + assert_eq!(german, ["Isolationsmodus beenden"]); + bar.app().run("object.exitIsolation", json!({"all": true})).unwrap(); + + // Pattern editing: back is Done, beside Save a Copy, Done and Cancel. + let c = rect(&mut bar.app(), 200.0); + bar.app().run("select.set", json!({"ids": [c]})).unwrap(); + bar.app().run("object.pattern.make", json!({"name": "Dots", "width": 20, "height": 20})).unwrap(); + assert_eq!(shown(&mut bar, Role::BUTTON), ["Cancel", "Done", "Done", "Save a Copy"]); + bar.app().run("object.pattern.cancel", json!({})).unwrap(); + + // Symbol editing mode: back leaves it. + let d = rect(&mut bar.app(), 300.0); + bar.app().run("select.set", json!({"ids": [d]})).unwrap(); + bar.app().run("symbol.new", json!({"name": "Box"})).unwrap(); + bar.app().run("symbol.edit", json!({"name": "Box"})).unwrap(); + assert_eq!(shown(&mut bar, Role::BUTTON), ["Exit Symbol Editing Mode"]); +} + /// The Control bar's Isolate Selected Object isolates a path inside a group that Direct /// Selection selected, and Exit Isolation Mode leaves with the path selected. Type, symbol /// instances, blends, two objects and an envelope's contents get no isolate button, and pattern diff --git a/docs/target-app-parity.md b/docs/target-app-parity.md index d0b91d16d1..9a799f0cf9 100644 --- a/docs/target-app-parity.md +++ b/docs/target-app-parity.md @@ -1371,6 +1371,7 @@ Moved from the ROADMAP's "Shipped so far" on 2026-10-10. Update it when a featur - The canvas context menu has Isolate Selected Path (`object.isolate`) when the selection is one path, a path selected inside a group or a compound path included, as the [help page](https://web.archive.org/web/20210601162814/https://helpx.adobe.com/pdf/illustrator_reference.pdf#page=324) lists it beside Isolate Selected Group. As VectorCraft's own rule, neither item shows for two or more objects, or for an object `object.isolate` refuses: a hidden or locked object, one in a hidden or locked group or layer, a guide while Lock Guides is on, and, while a symbol is edited, an object outside the symbol's art (`single_path_context_item_enters_isolation`, `isolation_context_item_follows_selected_kind`, `isolation_context_item_skips_objects_that_cannot_be_isolated`). - While an opacity mask is edited, Exit Isolation Mode (Esc, the isolation bar's back arrow, the Control bar's button, and the Layers panel menu's and canvas context menu's Exit Isolation Mode) leaves mask editing as Stop Editing Opacity Mask does, in one undo step: the mask keeps the edits, and the masked object is selected. While a pattern is edited, the Exit Isolation Mode item of the Layers panel menu and of the canvas context menu saves the pattern and leaves pattern editing, as Done does. - A click anywhere on the isolation bar, the isolated object's name included, outside its back arrow, the breadcrumbs of the levels above and its buttons leaves isolation mode altogether, nested isolation included, as Exit Isolation Mode does ([the help page](https://help.adobe.com/archive/en_US/illustrator/cs4/illustrator_cs4_help.pdf#page=207)). As VectorCraft's own rules, the click stops editing an opacity mask, leaves symbol editing mode even while a group inside the symbol's art is isolated, together with the isolation the mode was entered from, and does nothing while a pattern is edited; a drag across the bar does not leave (`isolation_bar_background_click_exits_nested_isolation`). + - Screen readers read the isolation bar's back arrow as a button named for what it does (Back One Level, Exit Isolation Mode, Exit Symbol Editing Mode, or Done while a pattern is edited), in the UI's language (`the_isolation_bars_controls_have_screen_reader_names`). - In isolation mode the Layers panel lists only the art of the isolated layer, sublayer or group, and lists the other layers and groups again when isolation mode ends ([the help page](https://help.adobe.com/archive/en_US/illustrator/cs5/illustrator_cs5_help.pdf#page=212)). As VectorCraft's own rules, the isolated layer, sublayer, group or object is the top row and opens on entering, the panel scrolls back to its row on leaving, search and filter look only inside it, nothing is dropped beside its row or into the empty space under the rows, Rename and Locate Object open no rows outside it, and rows highlighted outside it are no longer highlighted. With no row highlighted, Delete Selection and the trash do not delete a current layer outside it. New Layer, New Sublayer and Duplicate (in the panel menu and a row's context menu) are off, and OK in New Layer Options is an error, while the layer or copy they make would be outside it (`isolation_lists_only_the_isolated_art_and_exit_lists_every_layer_again`, `isolation_opens_the_isolated_row_and_keeps_drops_inside_it`, `isolation_drops_highlights_outside_the_isolated_art`, `isolation_keeps_rename_and_locate_to_the_rows_listed`, `isolation_keeps_delete_to_the_rows_listed`, `isolation_keeps_new_layers_to_the_rows_listed`, `new_layer_options_ok_checks_isolation_again`). - With a sublayer isolated, Exit Isolation Mode (the Layers panel menu item, the isolation bar's back arrow, the Control bar button and `object.exitIsolation`) goes back one layer at a time, isolating the parent layer, and leaves isolation mode from the top-level layer, as the [help page](https://helpx.adobe.com/illustrator/desktop/manage-objects/select-objects/isolate-objects.html) and an archived [help page](https://help.adobe.com/archive/en_US/illustrator/cs5/illustrator_cs5_help.pdf#page=213) describe. As VectorCraft's own rules, Esc and the top-level layer's crumb leave isolation mode from a sublayer at any depth (`object.exitIsolation {all: true}`), a sublayer's crumb isolates that sublayer, a hidden or locked parent layer is not isolated, and a step up records no undo step (`exit_isolation_goes_up_one_layer_from_a_sublayer`, `isolation_bar_back_button_steps_up_through_sublayers`, `escape_leaves_an_isolated_sublayer_in_one_step`). - Numeric spinner arrows keep stepping while held with the mouse past the click timeout and stop on release (#6307; `a_held_spinner_arrow_repeats`).