Skip to content

Commit

Permalink
Fix for defocusing text inputs react-grid-layout#315
Browse files Browse the repository at this point in the history
  • Loading branch information
schnerd committed Jan 8, 2020
1 parent 45075a8 commit 9825116
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions lib/utils/domFns.js
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

0 comments on commit 9825116

Please sign in to comment.