From 081d74141b131dbe501890a78f54d5d70d41c6e0 Mon Sep 17 00:00:00 2001 From: Tim Abbott Date: Fri, 18 Jun 2021 17:00:58 -0700 Subject: [PATCH] overlays: Don't close overlays when drawing selections. This fixes the following bug: * Open the streams modal. * Click and hold in the word "Streams" at the top. * Move pointer up out of the modal. * Release. * Expected: Some text is selected, but nothing else happens. * Actual: The modal disappears. We use the same fix we use for this class of issue in other places: checking for whether a range is selected, and if so, doing nothing. --- static/js/overlays.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/static/js/overlays.js b/static/js/overlays.js index ea47e59360..de43f697e2 100644 --- a/static/js/overlays.js +++ b/static/js/overlays.js @@ -231,6 +231,10 @@ export function initialize() { $("body").on("click", "div.overlay, div.overlay .exit", (e) => { let $target = $(e.target); + if (document.getSelection().type === "Range") { + return; + } + // if the target is not the div.overlay element, search up the node tree // until it is found. if ($target.is(".exit, .exit-sign, .overlay-content, .exit span")) {