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

Commit

Permalink
product/packing lookup does nothing when clicking on the single result
Browse files Browse the repository at this point in the history
  • Loading branch information
Dunkat committed Jun 1, 2017
1 parent 2273fcf commit 36fcbc2
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 @@ -46,7 +46,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 @@ -256,6 +257,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 @@ -274,7 +276,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 36fcbc2

Please sign in to comment.