Fixes #3397 : fake blur handled
This commit is contained in:
parent
ecb89d3670
commit
89f83b8cd7
@ -41,7 +41,8 @@ export default class AutoComplete extends Component {
|
|||||||
state = {
|
state = {
|
||||||
lastChangedValue: undefined,
|
lastChangedValue: undefined,
|
||||||
entry: null,
|
entry: null,
|
||||||
open: false
|
open: false,
|
||||||
|
fakeBlur: false
|
||||||
}
|
}
|
||||||
|
|
||||||
render () {
|
render () {
|
||||||
@ -102,6 +103,7 @@ export default class AutoComplete extends Component {
|
|||||||
case 'down':
|
case 'down':
|
||||||
const { menu } = muiAutocomplete.refs;
|
const { menu } = muiAutocomplete.refs;
|
||||||
menu.handleKeyDown(event);
|
menu.handleKeyDown(event);
|
||||||
|
this.setState({ fakeBlur: true });
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'enter':
|
case 'enter':
|
||||||
@ -135,17 +137,22 @@ export default class AutoComplete extends Component {
|
|||||||
this.setState({ entry, open: false });
|
this.setState({ entry, open: false });
|
||||||
}
|
}
|
||||||
|
|
||||||
onBlur = () => {
|
onBlur = (event) => {
|
||||||
const { onUpdateInput } = this.props;
|
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)
|
// input where text is allowed with the last selected value from the dropdown)
|
||||||
if (!onUpdateInput) {
|
if (!onUpdateInput) {
|
||||||
window.setTimeout(() => {
|
window.setTimeout(() => {
|
||||||
const { entry } = this.state;
|
const { entry, fakeBlur } = this.state;
|
||||||
|
|
||||||
|
if (fakeBlur) {
|
||||||
|
this.setState({ fakeBlur: false });
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
this.handleOnChange(entry);
|
this.handleOnChange(entry);
|
||||||
}, 100);
|
}, 200);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user