mirror of
https://github.com/danog/react-datalist-input.git
synced 2024-12-03 09:57:50 +01:00
set initalValue with every clean update
This commit is contained in:
parent
aad04be942
commit
c7579022c2
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "react-datalist-input",
|
||||
"version": "1.1.35",
|
||||
"version": "1.1.36",
|
||||
"description": "This package provides a react component as follows: an input field with a drop down menu to pick a possible option based on the current input.",
|
||||
"main": "./lib/DataListInput.js",
|
||||
"license": "MIT",
|
||||
|
@ -27,6 +27,17 @@ class DataListInput extends React.Component {
|
||||
window.addEventListener( 'click', this.onClickCloseMenu, false );
|
||||
}
|
||||
|
||||
componentDidUpdate = () => {
|
||||
const { currentInput, visible } = this.state;
|
||||
const { initialValue } = this.props;
|
||||
|
||||
// if we have an initialValue, we want to reset it everytime we update and are empty
|
||||
// also setting a new initialValue will trigger this
|
||||
if ( !currentInput && initialValue && !visible ) {
|
||||
this.setState( { currentInput: initialValue } );
|
||||
}
|
||||
}
|
||||
|
||||
componentWillUnmount = () => {
|
||||
window.removeEventListener( 'click', this.onClickCloseMenu );
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user