LibWeb: Fix moving through tabs with keyboard shortcuts

Previously, despite CTRL being held, the webpage elements such as
checboxes (if existing) could 'hijact' moving to the next and previous
tab with CTRL+TAB and CTRL+SHIFT+TAB.
This commit is contained in:
Rok Povsic 2025-03-04 11:26:56 +01:00 committed by Tim Flynn
parent 532f156f4a
commit cff48febf0
Notes: github-actions[bot] 2025-03-04 12:38:30 +00:00

View file

@ -1148,10 +1148,12 @@ EventResult EventHandler::handle_keydown(UIEvents::KeyCode key, u32 modifiers, u
GC::Ref<DOM::Document> document = *m_navigable->active_document();
if (key == UIEvents::KeyCode::Key_Tab) {
if (modifiers & UIEvents::KeyModifier::Mod_Shift)
return focus_previous_element() ? EventResult::Handled : EventResult::Dropped;
return focus_next_element() ? EventResult::Handled : EventResult::Dropped;
if (!(modifiers & UIEvents::KeyModifier::Mod_Ctrl)) {
if (key == UIEvents::KeyCode::Key_Tab) {
if (modifiers & UIEvents::KeyModifier::Mod_Shift)
return focus_previous_element() ? EventResult::Handled : EventResult::Dropped;
return focus_next_element() ? EventResult::Handled : EventResult::Dropped;
}
}
// https://html.spec.whatwg.org/multipage/interaction.html#close-requests