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 #1133 from metasfresh/dev-1130
Browse files Browse the repository at this point in the history
#1130 Fix improper handling of initialFocus in conjunction with clear value
  • Loading branch information
metas-mk committed Aug 15, 2017
2 parents edb3e19 + 4d6bca6 commit 08862a1
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions src/components/widget/Lookup/RawLookup.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class RawLookup extends Component {
}

componentDidMount() {
const { selected, defaultValue } = this.props;
const { selected, defaultValue, initialFocus } = this.props;

this.handleValueChanged();

Expand All @@ -44,15 +44,18 @@ class RawLookup extends Component {
let defaultKey = Object.keys(defaultValue)[0];
this.inputSearch.value = defaultValue[defaultKey];
}

if (initialFocus && !this.inputSearch.value) {
this.inputSearch.focus();
}
}

componentDidUpdate(prevProps) {
this.handleValueChanged();

const {
autoFocus, defaultValue, fireClickOutside, handleInputEmptyStatus,
filterWidget, initialFocus, lookupEmpty, localClearing,
resetLocalClearing, fireDropdownList
filterWidget, lookupEmpty, localClearing, resetLocalClearing, fireDropdownList
} = this.props;

const { shouldBeFocused } = this.state;
Expand All @@ -69,10 +72,6 @@ class RawLookup extends Component {
});
}

if (initialFocus && !this.inputSearch.value) {
this.inputSearch.focus();
}

defaultValue && prevProps.defaultValue !== defaultValue &&
handleInputEmptyStatus(false);

Expand Down

0 comments on commit 08862a1

Please sign in to comment.