From 538fe2cc31d9210ae6322ae2ccaf96c69a1850a5 Mon Sep 17 00:00:00 2001 From: Penar Musaraj Date: Thu, 7 Oct 2021 14:55:38 -0400 Subject: [PATCH] FIX: selection going missing in Safari (#14557) --- .../discourse/app/components/quote-button.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/app/assets/javascripts/discourse/app/components/quote-button.js b/app/assets/javascripts/discourse/app/components/quote-button.js index 3bd9f17e0b1..783b0ab8b1a 100644 --- a/app/assets/javascripts/discourse/app/components/quote-button.js +++ b/app/assets/javascripts/discourse/app/components/quote-button.js @@ -206,13 +206,6 @@ export default Component.extend(KeyEnterEscape, { // merge back all text nodes so they don't get messed up parent.normalize(); - // work around Safari that would sometimes lose the selection - if (isSafari) { - this._reselected = true; - selection.removeAllRanges(); - selection.addRange(clone); - } - // change the position of the button schedule("afterRender", () => { if (!this.element || this.isDestroying || this.isDestroyed) { @@ -234,6 +227,13 @@ export default Component.extend(KeyEnterEscape, { $quoteButton.offset({ top, left }); this.element.querySelector("button")?.focus(); + + // work around Safari that would sometimes lose the selection + if (isSafari) { + this._reselected = true; + selection.removeAllRanges(); + selection.addRange(clone); + } }); },