Skip to content

Commit

Permalink
Merge pull request #5134 from x-team/master
Browse files Browse the repository at this point in the history
  • Loading branch information
Rall3n committed Apr 5, 2022
2 parents 2d3d6af + 3f02ba6 commit 09f12f6
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/allow-event-bubbling-for-all-controls.md
@@ -0,0 +1,5 @@
---
'react-select': patch
---

Use defaultPrevented to skip duplicate event handler for clicking select.
7 changes: 4 additions & 3 deletions packages/react-select/src/Select.tsx
Expand Up @@ -1156,6 +1156,10 @@ export default class Select<
onControlMouseDown = (
event: React.MouseEvent<HTMLDivElement> | React.TouchEvent<HTMLDivElement>
) => {
// Event captured by dropdown indicator
if (event.defaultPrevented) {
return;
}
const { openMenuOnClick } = this.props;
if (!this.state.isFocused) {
if (openMenuOnClick) {
Expand Down Expand Up @@ -1202,7 +1206,6 @@ export default class Select<
this.openMenu('first');
}
event.preventDefault();
event.stopPropagation();
};
onClearIndicatorMouseDown = (
event: React.MouseEvent<HTMLDivElement> | React.TouchEvent<HTMLDivElement>
Expand All @@ -1217,7 +1220,6 @@ export default class Select<
}
this.clearValue();
event.preventDefault();
event.stopPropagation();
this.openAfterFocus = false;
if (event.type === 'touchend') {
this.focusInput();
Expand Down Expand Up @@ -1673,7 +1675,6 @@ export default class Select<
onTouchEnd: () => this.removeValue(opt),
onMouseDown: (e) => {
e.preventDefault();
e.stopPropagation();
},
}}
data={opt}
Expand Down

0 comments on commit 09f12f6

Please sign in to comment.