Skip to content

Commit

Permalink
Use defaultPrevented instead of internal flag
Browse files Browse the repository at this point in the history
  • Loading branch information
rkulinski committed Apr 4, 2022
1 parent 53cc8ce commit 150c020
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .changeset/allow-event-bubbling-for-all-controls.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
'react-select': patch
---

Use internal flag to prevent duplicate event handler for clicking select.
Use defaultPrevented to skip duplicate event handler for clicking select.
5 changes: 1 addition & 4 deletions packages/react-select/src/Select.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -594,7 +594,6 @@ export default class Select<
openAfterFocus = false;
scrollToFocusedOptionOnUpdate = false;
userIsDragging?: boolean;
dropdownEventAlreadyHandled = false;

// Refs
// ------------------------------
Expand Down Expand Up @@ -1158,8 +1157,7 @@ export default class Select<
event: React.MouseEvent<HTMLDivElement> | React.TouchEvent<HTMLDivElement>
) => {
// Event captured by dropdown indicator
if (this.dropdownEventAlreadyHandled) {
this.dropdownEventAlreadyHandled = false;
if (event.defaultPrevented) {
return;
}
const { openMenuOnClick } = this.props;
Expand Down Expand Up @@ -1198,7 +1196,6 @@ export default class Select<
) {
return;
}
this.dropdownEventAlreadyHandled = true;
if (this.props.isDisabled) return;
const { isMulti, menuIsOpen } = this.props;
this.focusInput();
Expand Down

0 comments on commit 150c020

Please sign in to comment.