mirror of
https://github.com/discourse/discourse.git
synced 2025-09-06 10:50:21 +08:00
FIX: Selections getting deselected on FireFox.
This commit is contained in:
parent
ad44d2a400
commit
7f1c474e5b
1 changed files with 4 additions and 3 deletions
|
@ -55,7 +55,8 @@ export default Ember.Component.extend({
|
|||
const { isIOS, isAndroid, isSafari } = this.capabilities;
|
||||
const showAtEnd = isMobileDevice || isIOS || isAndroid;
|
||||
|
||||
// used to work around Safari losing selection
|
||||
// Don't mess with the original range as it results in weird behaviours
|
||||
// where certain browsers will deselect the selection
|
||||
const clone = firstRange.cloneRange();
|
||||
|
||||
// create a marker element containing a single invisible character
|
||||
|
@ -63,9 +64,9 @@ export default Ember.Component.extend({
|
|||
markerElement.appendChild(document.createTextNode("\ufeff"));
|
||||
|
||||
// on mobile, collapse the range at the end of the selection
|
||||
if (showAtEnd) { firstRange.collapse(); }
|
||||
if (showAtEnd) { clone.collapse(); }
|
||||
// insert the marker
|
||||
firstRange.insertNode(markerElement);
|
||||
clone.insertNode(markerElement);
|
||||
|
||||
// retrieve the position of the marker
|
||||
const $markerElement = $(markerElement);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue