Skip to content
This repository has been archived by the owner on Dec 13, 2020. It is now read-only.

Commit

Permalink
Merge pull request #825 from metasfresh/dev-744
Browse files Browse the repository at this point in the history
product/packing lookup does nothing when clicking on the single result #744
  • Loading branch information
damianprzygodzki authored Jun 1, 2017
2 parents 2bbaf5a + 36fcbc2 commit 49f4395
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/components/widget/List/List.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,11 @@ class List extends Component {
} = this.props;
const {prevValue} = this.state;

if( prevValue !== option[Object.keys(option)[0]] ) {
if( prevValue !== (option && option[Object.keys(option)[0]] )) {
if(lookupList){
onChange(properties[0].field, option);

this.setState({
option && this.setState({
selectedItem: option,
prevValue: option[Object.keys(option)[0]]
});
Expand Down
11 changes: 9 additions & 2 deletions src/components/widget/List/RawList.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ class RawList extends Component {

if(list.length > 0) {
this.setState({
dropdownList: dropdown.concat(list)
dropdownList: dropdown.concat(list),
selected: list[0]
});
}
}
Expand Down Expand Up @@ -263,6 +264,7 @@ class RawList extends Component {

handleKeyDown = (e) => {
const {selected, isOpen} = this.state;
const {onSelect} = this.props;

if(e.keyCode > 47 && e.keyCode < 123){
this.navigateToAlphanumeric(e.key);
Expand All @@ -281,7 +283,12 @@ class RawList extends Component {
if(isOpen){
e.stopPropagation();
}
this.handleSelect(selected);
if(selected){
this.handleSelect(selected);
} else {
onSelect(null);
}

break;
case 'Escape':
e.preventDefault();
Expand Down

0 comments on commit 49f4395

Please sign in to comment.