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

Commit

Permalink
Fix improper handling of initialFocus in conjunction with clear value #…
Browse files Browse the repository at this point in the history
  • Loading branch information
wiadev committed Aug 12, 2017
1 parent edb3e19 commit 4d6bca6
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 4d6bca6

Please sign in to comment.