FIX: sometimes quote button did nothing on Firefox

This commit is contained in:
Sam 2017-11-20 11:14:44 +11:00
parent 41673c322c
commit ff1ce175fc
1 changed files with 12 additions and 1 deletions

View File

@ -40,9 +40,18 @@ export default Ember.Component.extend({
}
}
quoteState.selected(postId, selectedText());
const _selectedText = selectedText();
quoteState.selected(postId, _selectedText);
this.set('visible', quoteState.buffer.length > 0);
// avoid hard loops in quote selection unconditionally
// this can happen if you triple click text in firefox
if (this._prevSelection === _selectedText) {
return;
}
this._prevSelection = _selectedText;
// on Desktop, shows the button at the beginning of the selection
// on Mobile, shows the button at the end of the selection
const isMobileDevice = this.site.isMobileDevice;
@ -101,12 +110,14 @@ export default Ember.Component.extend({
const onSelectionChanged = _.debounce(() => this._selectionChanged(), wait);
$(document).on("mousedown.quote-button", e => {
this._prevSelection = null;
this._isMouseDown = true;
this._reselected = false;
if ($(e.target).closest('.quote-button, .create, .share, .reply-new').length === 0) {
this._hideButton();
}
}).on("mouseup.quote-button", () => {
this._prevSelection = null;
this._isMouseDown = false;
onSelectionChanged();
}).on("selectionchange.quote-button", () => {