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
10 changes: 6 additions & 4 deletions src/components/Picklist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,9 +167,12 @@ class Picklist extends Component {
}

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

handleBlur() {
Expand All @@ -185,7 +188,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
2 changes: 2 additions & 0 deletions src/components/Picklist/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ const initialState = { value: { name: 'option 3', label: 'Central Park' } };
onChange={value => setState({ value })}
value={state.value}
label="Select Building"
onClick={() => console.log('click')}
onFocus={() => console.log('focus')}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove these console

hideLabel
>
<Option name="header" label="Your Buildings" variant="header" />
Expand Down