Skip to content
This repository was archived by the owner on Jul 19, 2019. It is now read-only.

Commit 3cffb47

Browse files
CMTegnerwhichsteveyp
authored andcommitted
[fixed] Workaround for selection bug in IE, fixes #80
1 parent c63e4a3 commit 3cffb47

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

lib/Autocomplete.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,18 @@ let Autocomplete = React.createClass({
8989
if (this.keyDownHandlers[event.key])
9090
this.keyDownHandlers[event.key].call(this, event)
9191
else {
92+
const { selectionStart, value } = event.target
93+
if (value === this.state.value)
94+
// Nothing changed, no need to do anything. This also prevents
95+
// our workaround below from nuking user-made selections
96+
return
9297
this.setState({
9398
highlightedIndex: null,
9499
isOpen: true
100+
}, () => {
101+
// Restore caret position before autocompletion process
102+
// to work around a setSelectionRange bug in IE (#80)
103+
this.refs.input.selectionStart = selectionStart
95104
})
96105
}
97106
},

0 commit comments

Comments
 (0)