1
0
mirror of https://github.com/roytam1/UXP.git synced 2026-05-26 13:58:49 +00:00

Issue #2532 - Don't do PreventDefault for escape key if <select> dropdown is not shown

We always use PreventDefault for <select> element, which is problematic if modal
dialog is on as it prevents cancelling the dialog. We fix it by not blocking the
default action if <select> is not shown.

See Bug 1649278
This commit is contained in:
Moonchild
2024-06-15 12:33:06 +02:00
committed by roytam1
parent f50948c82a
commit 368ee51d86
+11 -2
View File
@@ -2236,11 +2236,20 @@ nsListControlFrame::KeyDown(nsIDOMEvent* aKeyEvent)
return NS_OK;
}
// We don't want to preventDefault for escape key if the dropdown
// popup is not shown.
// Need to do the check before AboutToRollup because AboutToRollup
// may update the dropdown flags.
bool doPreventDefault =
!mComboboxFrame || mComboboxFrame->IsDroppedDownOrHasParentPopup();
AboutToRollup();
// If the select element is a dropdown style, Enter key should be
// If the select element is a dropdown style, Escape key should be
// consumed everytime since Escape key may be pressed accidentally after
// the dropdown is closed by Escepe key.
aKeyEvent->PreventDefault();
if (doPreventDefault) {
aKeyEvent->PreventDefault();
}
return NS_OK;
}
case NS_VK_PAGE_UP: {