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
No known key found for this signature in database
GPG Key ID: B9606168D2FFD9F5
1 changed files with 8 additions and 2 deletions

View File

@ -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();
}
});