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

#1130 Fix improper handling of initialFocus in conjunction with clear value #1133

Merged
merged 1 commit into from
Aug 15, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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