From 564e546ff0bd78cc7ba770b53377457bf1ef88d6 Mon Sep 17 00:00:00 2001 From: Luke Warlow Date: Thu, 13 Jun 2024 18:36:18 +0200 Subject: [PATCH] LibWeb: Prevent select.click() opening the dropdown No other browser allows opening the select element dropdown with the select.click() function. This change stops this happening in Ladybird. --- Userland/Libraries/LibWeb/HTML/HTMLSelectElement.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Userland/Libraries/LibWeb/HTML/HTMLSelectElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLSelectElement.cpp index ab5386d775..06017584f1 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLSelectElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLSelectElement.cpp @@ -431,9 +431,10 @@ WebIDL::ExceptionOr HTMLSelectElement::show_picker() return {}; } -void HTMLSelectElement::activation_behavior(DOM::Event const&) +void HTMLSelectElement::activation_behavior(DOM::Event const& event) { - show_the_picker_if_applicable(); + if (event.is_trusted()) + show_the_picker_if_applicable(); } void HTMLSelectElement::did_select_item(Optional const& id)