Fixes #3397 : fake blur handled

This commit is contained in:
Nicolas Gotchac 2016-11-14 16:11:00 +01:00
parent ecb89d3670
commit 89f83b8cd7

View File

@ -41,7 +41,8 @@ export default class AutoComplete extends Component {
state = {
lastChangedValue: undefined,
entry: null,
open: false
open: false,
fakeBlur: false
}
render () {
@ -102,6 +103,7 @@ export default class AutoComplete extends Component {
case 'down':
const { menu } = muiAutocomplete.refs;
menu.handleKeyDown(event);
this.setState({ fakeBlur: true });
break;
case 'enter':
@ -135,17 +137,22 @@ export default class AutoComplete extends Component {
this.setState({ entry, open: false });
}
onBlur = () => {
onBlur = (event) => {
const { onUpdateInput } = this.props;
// TODO: Handle blur gracefully where we use onUpdateInput (currently replaces input
// TODO: Handle blur gracefully where we use onUpdateInput (currently replaces
// input where text is allowed with the last selected value from the dropdown)
if (!onUpdateInput) {
window.setTimeout(() => {
const { entry } = this.state;
const { entry, fakeBlur } = this.state;
if (fakeBlur) {
this.setState({ fakeBlur: false });
return;
}
this.handleOnChange(entry);
}, 100);
}, 200);
}
}