mirror of
https://github.com/danog/react-datalist-input.git
synced 2024-12-03 18:07:55 +01:00
fixed bugs
This commit is contained in:
parent
a66f5cd596
commit
0f725f862e
@ -112,8 +112,14 @@ class DataListInput extends React.Component {
|
|||||||
* @param selectedItem
|
* @param selectedItem
|
||||||
*/
|
*/
|
||||||
onSelect = (selectedItem) => {
|
onSelect = (selectedItem) => {
|
||||||
if (selectedItem.key === this.state.lastValidItem.key) {
|
if (this.state.lastValidItem !== undefined && selectedItem.key === this.state.lastValidItem.key){
|
||||||
// do nothing onClick if key has not change since the last selection
|
// do not trigger the callback function
|
||||||
|
// but still change state to fit new selection
|
||||||
|
this.setState({
|
||||||
|
currentInput: selectedItem.label,
|
||||||
|
visible: false,
|
||||||
|
focusIndex: -1,
|
||||||
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// change state to fit new selection
|
// change state to fit new selection
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "react-datalist-input",
|
"name": "react-datalist-input",
|
||||||
"version": "1.0.2",
|
"version": "1.0.3",
|
||||||
"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.",
|
"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": "build/index.js",
|
"main": "build/index.js",
|
||||||
"repository": {
|
"repository": {
|
||||||
|
10
src/index.js
10
src/index.js
@ -119,8 +119,14 @@ class DataListInput extends React.Component {
|
|||||||
* @param selectedItem
|
* @param selectedItem
|
||||||
*/
|
*/
|
||||||
onSelect(selectedItem) {
|
onSelect(selectedItem) {
|
||||||
if (selectedItem.key === this.state.lastValidItem.key) {
|
if (this.state.lastValidItem !== undefined && selectedItem.key === this.state.lastValidItem.key){
|
||||||
// do nothing onClick if key has not change since the last selection
|
// do not trigger the callback function
|
||||||
|
// but still change state to fit new selection
|
||||||
|
this.setState({
|
||||||
|
currentInput: selectedItem.label,
|
||||||
|
visible: false,
|
||||||
|
focusIndex: -1,
|
||||||
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// change state to fit new selection
|
// change state to fit new selection
|
||||||
|
Loading…
Reference in New Issue
Block a user