From d62d016be3aa09741ede995d2e6e028e6970fd94 Mon Sep 17 00:00:00 2001 From: Klaas van Schelven Date: Fri, 29 Aug 2025 09:34:14 +0200 Subject: [PATCH] When selecting text in the stacktrace frameHeader, don't toggle the frame The frameheader is a typical target for copy/paste actions (filenames/paths) and having stuff jump around right after selecting is annoying --- static/js/issue_stacktrace.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/static/js/issue_stacktrace.js b/static/js/issue_stacktrace.js index a503803..d21b753 100644 --- a/static/js/issue_stacktrace.js +++ b/static/js/issue_stacktrace.js @@ -88,6 +88,17 @@ function expandSection(element) { } function toggleFrameVisibility(frameHeader) { + console.log("toggling frame visibility"); + const selection = window.getSelection().toString(); + if (selection.length > 0) { + // don't toggle if the user is selecting text (which one might do to copy a + // filename or similar); the assumption here is: if there's a selection, + // it was just created using the mouse because non-selecting mouseclick + // deselect all text before the click is triggered. this assumption + // holds on desktop browsers; on mobile we might need to refine this. + return; + } + const frameDetails = frameHeader.parentNode.querySelector(".js-frame-details"); if (frameDetails.getAttribute("data-collapsed") === "true") { expandSection(frameDetails);