File tree Expand file tree Collapse file tree 2 files changed +12
-4
lines changed Expand file tree Collapse file tree 2 files changed +12
-4
lines changed Original file line number Diff line number Diff line change 22
33## NEXT VERSION
44
5+ - fix: input loses focus on unmount
6+
57## v1.10.8 (2020-08-11)
68
79- fix: scroll position would be reset to top if column becomes frozen
Original file line number Diff line number Diff line change @@ -13,20 +13,26 @@ export function addUserSelectStyles(doc) {
1313 styleEl = doc . createElement ( 'style' ) ;
1414 styleEl . type = 'text/css' ;
1515 styleEl . id = 'react-draggable-style-el' ;
16- styleEl . innerHTML = '.react-draggable-transparent-selection *::-moz-selection {background: transparent ;}\n' ;
17- styleEl . innerHTML += '.react-draggable-transparent-selection *::selection {background: transparent ;}\n' ;
16+ styleEl . innerHTML = '.react-draggable-transparent-selection *::-moz-selection {all: inherit ;}\n' ;
17+ styleEl . innerHTML += '.react-draggable-transparent-selection *::selection {all: inherit ;}\n' ;
1818 doc . getElementsByTagName ( 'head' ) [ 0 ] . appendChild ( styleEl ) ;
1919 }
2020 if ( doc . body ) addClassName ( doc . body , 'react-draggable-transparent-selection' ) ;
2121}
2222
2323export function removeUserSelectStyles ( doc ) {
24+ if ( ! doc ) return ;
2425 try {
25- if ( doc && doc . body ) removeClassName ( doc . body , 'react-draggable-transparent-selection' ) ;
26+ if ( doc . body ) removeClassName ( doc . body , 'react-draggable-transparent-selection' ) ;
2627 if ( doc . selection ) {
2728 doc . selection . empty ( ) ;
2829 } else {
29- window . getSelection ( ) . removeAllRanges ( ) ; // remove selection caused by scroll
30+ // Remove selection caused by scroll, unless it's a focused input
31+ // (we use doc.defaultView in case we're in an iframe)
32+ const selection = ( doc . defaultView || window ) . getSelection ( ) ;
33+ if ( selection && selection . type !== 'Caret' ) {
34+ selection . removeAllRanges ( ) ;
35+ }
3036 }
3137 } catch ( e ) {
3238 // probably IE
You can’t perform that action at this time.
0 commit comments