Skip to content

A platform for community discussion. Free, open, simple.

PERF: stop firing superfluous onSelectionChange

Sam Saffronfa96054acf61
diff --git a/app/assets/javascripts/discourse/components/quote-button.js b/app/assets/javascripts/discourse/components/quote-button.js
index 8f7d464543b..180654099fa 100644
--- a/app/assets/javascripts/discourse/components/quote-button.js
+++ b/app/assets/javascripts/discourse/components/quote-button.js
@@ -188,10 +188,16 @@ export default Component.extend({
.on("mouseup.quote-button", () => {
this._prevSelection = null;
this._isMouseDown = false;
- onSelectionChanged();
+ if (document.activeElement === document.body) {
+ onSelectionChanged();
+ }
})
.on("selectionchange.quote-button", () => {
- if (!this._isMouseDown && !this._reselected) {
+ if (
+ !this._isMouseDown &&
+ !this._reselected &&
+ document.activeElement === document.body
+ ) {
onSelectionChanged();
}
});