Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions lib/utils/domFns.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,14 +158,20 @@ export function addUserSelectStyles(doc: ?Document) {
}

export function removeUserSelectStyles(doc: ?Document) {
if (!doc) return;
try {
if (doc && doc.body) removeClassName(doc.body, 'react-draggable-transparent-selection');
if (doc.body) removeClassName(doc.body, 'react-draggable-transparent-selection');
// $FlowIgnore: IE
if (doc.selection) {
// $FlowIgnore: IE
doc.selection.empty();
} else {
window.getSelection().removeAllRanges(); // remove selection caused by scroll
// Remove selection caused by scroll, unless it's a focused input
// (we use doc.defaultView in case we're in an iframe)
const selection = (doc.defaultView || window).getSelection();
if (selection && selection.type !== 'Caret') {
selection.removeAllRanges();
}
}
} catch (e) {
// probably IE
Expand Down