From 1b2e1c19e124502049c3888bf2ebb234d9a0a65e Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Tue, 15 Feb 2022 13:51:17 +0100 Subject: [PATCH] LibWeb: Don't trigger page load for fragment navigation within same URL --- Userland/Libraries/LibWeb/Page/EventHandler.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Userland/Libraries/LibWeb/Page/EventHandler.cpp b/Userland/Libraries/LibWeb/Page/EventHandler.cpp index 962011677a..ae73ed7b08 100644 --- a/Userland/Libraries/LibWeb/Page/EventHandler.cpp +++ b/Userland/Libraries/LibWeb/Page/EventHandler.cpp @@ -248,9 +248,8 @@ bool EventHandler::handle_mousedown(const Gfx::IntPoint& position, unsigned butt if (button == GUI::MouseButton::Primary) { if (href.starts_with("javascript:")) { document->run_javascript(href.substring_view(11, href.length() - 11)); - } else if (href.starts_with('#')) { - auto anchor = href.substring_view(1, href.length() - 1); - m_browsing_context.scroll_to_anchor(anchor); + } else if (!url.fragment().is_null() && url.equals(document->url(), AK::URL::ExcludeFragment::Yes)) { + m_browsing_context.scroll_to_anchor(url.fragment()); } else { document->set_active_element(link); if (m_browsing_context.is_top_level()) {