Use the new onClose
autocomplete prop
This commit is contained in:
parent
84116130f6
commit
cd6ab07217
@ -44,7 +44,6 @@ export default class AutoComplete extends Component {
|
|||||||
lastChangedValue: undefined,
|
lastChangedValue: undefined,
|
||||||
entry: null,
|
entry: null,
|
||||||
open: false,
|
open: false,
|
||||||
fakeBlur: false,
|
|
||||||
dataSource: []
|
dataSource: []
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -78,7 +77,7 @@ export default class AutoComplete extends Component {
|
|||||||
onUpdateInput={ onUpdateInput }
|
onUpdateInput={ onUpdateInput }
|
||||||
searchText={ value }
|
searchText={ value }
|
||||||
onFocus={ this.onFocus }
|
onFocus={ this.onFocus }
|
||||||
onBlur={ this.onBlur }
|
onClose={ this.onClose }
|
||||||
animation={ PopoverAnimationVertical }
|
animation={ PopoverAnimationVertical }
|
||||||
filter={ filter }
|
filter={ filter }
|
||||||
popoverProps={ { open } }
|
popoverProps={ { open } }
|
||||||
@ -121,7 +120,6 @@ export default class AutoComplete extends Component {
|
|||||||
case 'down':
|
case 'down':
|
||||||
const { menu } = muiAutocomplete.refs;
|
const { menu } = muiAutocomplete.refs;
|
||||||
menu && menu.handleKeyDown(event);
|
menu && menu.handleKeyDown(event);
|
||||||
this.setState({ fakeBlur: true });
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'enter':
|
case 'enter':
|
||||||
@ -155,22 +153,12 @@ export default class AutoComplete extends Component {
|
|||||||
this.setState({ entry, open: false });
|
this.setState({ entry, open: false });
|
||||||
}
|
}
|
||||||
|
|
||||||
onBlur = (event) => {
|
onClose = (event) => {
|
||||||
const { onUpdateInput } = this.props;
|
const { onUpdateInput } = this.props;
|
||||||
|
|
||||||
// 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) {
|
if (!onUpdateInput) {
|
||||||
window.setTimeout(() => {
|
const { entry } = this.state;
|
||||||
const { entry, fakeBlur } = this.state;
|
|
||||||
|
|
||||||
if (fakeBlur) {
|
|
||||||
this.setState({ fakeBlur: false });
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.handleOnChange(entry);
|
this.handleOnChange(entry);
|
||||||
}, 200);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user