mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-11-29 01:34:29 +01:00
Swatches: Swatch Libraries and Show Swatch Kinds report that they open a menu
The two footer buttons open menus but set no popup kind, so the footer drew no dropdown arrow under them and screen readers were not told they open a menu. Both now call `.popup(PopupKind::Menu)`, as the menu buttons in the Brushes, Graphic Styles, Symbols and library panel footers do. `panel_harness` gains `Panel::popup_kind`, which reads the popup kind a control reports from the accessibility tree.
This commit is contained in:
1 parent
82d9ff0182
commit
441d9161a5
3 files changed
+24
-3
No files matched your search
@@ -14,7 +14,7 @@ use craft::color_ui::palette::{SwatchColor, SwatchEntry, SwatchGroup, SwatchKind
|
||||
use craft::color_ui::ui::{SwatchKey, SwatchesPanel, SwatchesState};
|
||||
use craft::theme::Srgba;
|
||||
use craft::ui::choice::SwatchFace;
|
||||
use craft::ui::contract::{Bind, DropPlace, ListDrag, MemoProps, SelectMode};
|
||||
use craft::ui::contract::{Bind, DropPlace, ListDrag, MemoProps, PopupKind, SelectMode};
|
||||
use craft::ui::contract::{Entry, Props as _, Show as _, ShowContainer as _, Trigger};
|
||||
use craft::ui::menu::{Menu, MenuItem};
|
||||
use craft::ui::patterns::presets::{PresetEvent, PresetView, ThumbInfo};
|
||||
@@ -778,8 +778,10 @@ fn footer(app: &mut VectorcraftApp, ui: &mut Ui) {
|
||||
// Libraries, Show Swatch Kinds and the edit action sit at the start edge; Delete at the end edge, then New Swatch
|
||||
// and New Color Group before it.
|
||||
let actions = [
|
||||
FooterAction::new(icon("library"), tl!(SwatchLibraries::MENU)).pressed(library_panel::any_open::<SwatchLibraries>(&app.ui)),
|
||||
FooterAction::new(icon("dc-swatch-kinds"), tl!("Show Swatch Kinds")).pressed(kind != Kind::All),
|
||||
FooterAction::new(icon("library"), tl!(SwatchLibraries::MENU))
|
||||
.popup(PopupKind::Menu)
|
||||
.pressed(library_panel::any_open::<SwatchLibraries>(&app.ui)),
|
||||
FooterAction::new(icon("dc-swatch-kinds"), tl!("Show Swatch Kinds")).popup(PopupKind::Menu).pressed(kind != Kind::All),
|
||||
edit,
|
||||
FooterAction::new(icon("trash-2"), tl!("Delete Swatch"))
|
||||
.enabled(!del.is_empty())
|
||||
|
||||
@@ -170,6 +170,20 @@ fn a_foreign_swatch_row_payload_cannot_move_or_replace_local_swatches() {
|
||||
assert_eq!(doc(&app).swatches, before.swatches);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_footer_menu_buttons_report_that_they_open_a_menu() {
|
||||
use crate::tests::panel_harness::Panel;
|
||||
use craft::ui::contract::PopupKind;
|
||||
|
||||
let panel = Panel::new(app(), show);
|
||||
for name in [SwatchLibraries::MENU, "Show Swatch Kinds"] {
|
||||
assert_eq!(panel.popup_kind(name), Some(PopupKind::Menu), "{name}");
|
||||
}
|
||||
for name in ["Delete Swatch", "New Swatch", "New Color Group"] {
|
||||
assert_eq!(panel.popup_kind(name), None, "{name}");
|
||||
}
|
||||
}
|
||||
|
||||
/// Art `ids` dragged off the canvas.
|
||||
fn art_drag(app: &VectorcraftApp, ids: Vec<vectorcraft_doc::NodeId>) -> PanelDrag {
|
||||
let (document, reverts) = app.session.active().map_or((0, 0), |st| (st.uid, st.reverts));
|
||||
|
||||
@@ -412,6 +412,11 @@ impl Panel {
|
||||
self.fixture.tree().toggled_of(self.look(name).node)
|
||||
}
|
||||
|
||||
/// The kind of popup the control named `name` reports that it opens.
|
||||
pub(crate) fn popup_kind(&self, name: &str) -> Option<craft::ui::contract::PopupKind> {
|
||||
self.fixture.tree().has_popup_of(self.look(name).node)
|
||||
}
|
||||
|
||||
/// Whether the control named `name` has the focus.
|
||||
pub(crate) fn focused(&self, name: &str) -> bool {
|
||||
self.fixture.tree().focused_key() == self.look(name).node
|
||||
|
||||
Reference in new issue
Block a user