From 05dd46f9e3643d490bd8e727482b874742e6f739 Mon Sep 17 00:00:00 2001 From: Sebastian Zaha Date: Fri, 21 Jul 2023 16:42:48 +0200 Subject: [PATCH] LibWeb: Do not fire click event if mouseup/down elements do not match Click event logic should start as false, and after checking if the mousedown and subsequent mouseup have been on the same element, and if the node dispatches events it can become true. This fixes the issue that clicking anywhere on the page, then dragging the mouse on top of a link or button, then releasing triggers the link. This is also happening when selecting text, if the selection stops over a link, the page navigates. --- Userland/Libraries/LibWeb/Page/EventHandler.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Userland/Libraries/LibWeb/Page/EventHandler.cpp b/Userland/Libraries/LibWeb/Page/EventHandler.cpp index 83631600d1..24f5cbedac 100644 --- a/Userland/Libraries/LibWeb/Page/EventHandler.cpp +++ b/Userland/Libraries/LibWeb/Page/EventHandler.cpp @@ -242,7 +242,7 @@ bool EventHandler::handle_mouseup(CSSPixelPoint position, unsigned button, unsig node->dispatch_event(UIEvents::MouseEvent::create_from_platform_event(node->realm(), UIEvents::EventNames::mouseup, offset, client_offset, page_offset, buttons, button).release_value_but_fixme_should_propagate_errors()); handled_event = true; - bool run_activation_behavior = true; + bool run_activation_behavior = false; if (node.ptr() == m_mousedown_target) { if (button == GUI::MouseButton::Primary) run_activation_behavior = node->dispatch_event(UIEvents::MouseEvent::create_from_platform_event(node->realm(), UIEvents::EventNames::click, offset, client_offset, page_offset, button).release_value_but_fixme_should_propagate_errors());