PERF: stop firing superfluous onSelectionChange

onSelectionChanged fires a debounced event that calls window.getSelection()

window.getSelection() is reasonably expensive. There is no reason to do any
of this work if we have an input field focused, that is not how quote works
This commit is contained in:
Sam Saffron
2020-04-23 17:51:23 +10:00
parent 7132c50f3b
commit fa96054acf

View File

@@ -188,10 +188,16 @@ export default Component.extend({
.on("mouseup.quote-button", () => { .on("mouseup.quote-button", () => {
this._prevSelection = null; this._prevSelection = null;
this._isMouseDown = false; this._isMouseDown = false;
onSelectionChanged(); if (document.activeElement === document.body) {
onSelectionChanged();
}
}) })
.on("selectionchange.quote-button", () => { .on("selectionchange.quote-button", () => {
if (!this._isMouseDown && !this._reselected) { if (
!this._isMouseDown &&
!this._reselected &&
document.activeElement === document.body
) {
onSelectionChanged(); onSelectionChanged();
} }
}); });