Do not carry keyboard highlight into accessible menu activation

This commit is contained in:
Dylan M. Taylor committed 2026-11-21 13:35:27 -05:00
1 parent 2b7f93a914
commit d86394cd5d
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");
}
}