Skip to content

A platform for community discussion. Free, open, simple.

FIX: Quote selection in IE11

David Taylor27ed60bad09d
diff --git a/app/assets/javascripts/discourse/components/quote-button.js.es6 b/app/assets/javascripts/discourse/components/quote-button.js.es6
index 1c6da30615e..b26f891d735 100644
--- a/app/assets/javascripts/discourse/components/quote-button.js.es6
+++ b/app/assets/javascripts/discourse/components/quote-button.js.es6
@@ -60,7 +60,7 @@ export default Ember.Component.extend({
// 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;
- const { isIOS, isAndroid, isSafari, isOpera } = this.capabilities;
+ const { isIOS, isAndroid, isSafari, isOpera, isIE11 } = this.capabilities;
const showAtEnd = isMobileDevice || isIOS || isAndroid || isOpera;
// Don't mess with the original range as it results in weird behaviours
@@ -88,7 +88,10 @@ export default Ember.Component.extend({
const parent = markerElement.parentNode;
parent.removeChild(markerElement);
// merge back all text nodes so they don't get messed up
- parent.normalize();
+ if (!isIE11) {
+ // Skip this fix in IE11 - .normalize causes the selection to change
+ parent.normalize();
+ }
// work around Safari that would sometimes lose the selection
if (isSafari) {
diff --git a/app/assets/javascripts/discourse/pre-initializers/sniff-capabilities.js.es6 b/app/assets/javascripts/discourse/pre-initializers/sniff-capabilities.js.es6
index 585fff87538..66d1085692b 100644
--- a/app/assets/javascripts/discourse/pre-initializers/sniff-capabilities.js.es6
+++ b/app/assets/javascripts/discourse/pre-initializers/sniff-capabilities.js.es6
@@ -30,6 +30,7 @@ export default {
return p.toString() === "[object SafariRemoteNotification]";
})(!window["safari"] || safari.pushNotification);
caps.isChrome = !!window.chrome && !caps.isOpera;
+ caps.isIE11 = !!ua.match(/Trident.*rv\:11\./);
caps.canPasteImages = caps.isChrome || caps.isFirefox;
}