Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: onFocus and onClick in Picklist triggered when it should not #2528

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
9 changes: 6 additions & 3 deletions src/components/Picklist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ class Picklist extends Component {
this.setState({
isOpen: false,
});
this.focus();
}

handleInputClick(event) {
Expand All @@ -167,9 +168,12 @@ class Picklist extends Component {
}

handleFocus() {
const { isOpen } = this.state;
const { onFocus, value } = this.props;
const eventValue = value || null;
onFocus(eventValue);
if (!isOpen) {
const eventValue = value || null;
onFocus(eventValue);
}
}

handleBlur() {
Expand All @@ -185,7 +189,6 @@ class Picklist extends Component {
const { label, name, icon, value } = option;
this.closeMenu();
setTimeout(() => {
this.focus();
return onChange({ label, name, icon, value });
}, 0);
}
Expand Down