mirror of
https://github.com/storytold/craft-libs.git
synced 2026-11-25 03:52:45 +01:00
Do not carry keyboard highlight into accessible menu activation
This commit is contained in:
2 files changed
+7
No files matched your search
@@ -509,6 +509,9 @@ pub(crate) fn input_hook(ctx: &Context, input: &RawInput, events: &mut Vec<Arriv
|
||||
stage.keyed |= matches!(read, KeyEvent::Press { .. } | KeyEvent::Text(_) | KeyEvent::Clip { .. });
|
||||
visible = match &read {
|
||||
KeyEvent::PointerPress => Some(false),
|
||||
// An accessibility activation is not the preceding key: a menu it opens must wait for its own navigation.
|
||||
KeyEvent::Access(action)
|
||||
if matches!(action.kind(), raw_input::ActionKind::Click | raw_input::ActionKind::ShowContextMenu) => Some(false),
|
||||
KeyEvent::Press { .. } | KeyEvent::Text(_) => Some(true),
|
||||
_ => visible,
|
||||
};
|
||||
|
||||
@@ -218,8 +218,12 @@ fn a_menu_opener_accepts_accessibility_activation() {
|
||||
});
|
||||
});
|
||||
fixture.settle();
|
||||
fixture.key(egui::Key::Escape, egui::Modifiers::NONE).settle();
|
||||
let opener = fixture.by_label("Options").expect("the opener");
|
||||
fixture.access(craft_ui::testing::focus::AccessActionKind::Click, &opener).settle();
|
||||
assert!(fixture.by_label("An option").is_some(), "{trigger:?} opens through accessibility");
|
||||
assert!(!craft_ui::runtime::focus::keyboard_in_menu(fixture.ctx()), "an accessibility activation does not inherit an earlier key");
|
||||
fixture.key(egui::Key::ArrowDown, egui::Modifiers::NONE).settle();
|
||||
assert!(craft_ui::runtime::focus::keyboard_in_menu(fixture.ctx()), "a later key drives the menu");
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user