FIX: safari would lose selection sometimes

This commit is contained in:
Régis Hanol 2016-12-05 11:08:30 +01:00
parent 37b256e7f2
commit 965b38ff2a

View File

@ -38,6 +38,9 @@ export default Ember.Component.extend({
}
}
// used to work around Safari losing selection
const clone = firstRange.cloneRange();
this.get("quoteState").setProperties({ postId, buffer: selectedText() });
// on Desktop, shows the button at the beginning of the selection
@ -64,6 +67,11 @@ export default Ember.Component.extend({
// remove the marker
markerElement.parentNode.removeChild(markerElement);
// work around Safari that would sometimes lose the selection
const s = window.getSelection();
s.removeAllRanges();
s.addRange(clone);
// change the position of the button
Ember.run.scheduleOnce("afterRender", () => {
let top = markerOffset.top;