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

Allow event bubbling for dropdown click #5089

Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/allow-event-bubbling-for-all-controls.md
@@ -0,0 +1,5 @@
---
'react-select': patch
---

Replace stopPropagation with target check.
7 changes: 6 additions & 1 deletion packages/react-select/src/Select.tsx
Expand Up @@ -1156,6 +1156,11 @@ export default class Select<
onControlMouseDown = (
event: React.MouseEvent<HTMLDivElement> | React.TouchEvent<HTMLDivElement>
) => {
// Event captured by dropdown indicator
// @ts-ignore
if (event.target.closest('.DropdownIndicatorContainer')) {
rkulinski marked this conversation as resolved.
Show resolved Hide resolved
return;
}
const { openMenuOnClick } = this.props;
if (!this.state.isFocused) {
if (openMenuOnClick) {
Expand Down Expand Up @@ -1202,7 +1207,6 @@ export default class Select<
this.openMenu('first');
}
event.preventDefault();
event.stopPropagation();
};
onClearIndicatorMouseDown = (
event: React.MouseEvent<HTMLDivElement> | React.TouchEvent<HTMLDivElement>
Expand Down Expand Up @@ -1776,6 +1780,7 @@ export default class Select<

return (
<DropdownIndicator
className="DropdownIndicatorContainer"
{...commonProps}
innerProps={innerProps}
isDisabled={isDisabled}
Expand Down
Expand Up @@ -220,7 +220,7 @@ exports[`defaults - snapshot 1`] = `
/>
<div
aria-hidden="true"
class=" emotion-9"
class="DropdownIndicatorContainer emotion-9"
>
<svg
aria-hidden="true"
Expand Down
Expand Up @@ -220,7 +220,7 @@ exports[`defaults - snapshot 1`] = `
/>
<div
aria-hidden="true"
class=" emotion-9"
class="DropdownIndicatorContainer emotion-9"
>
<svg
aria-hidden="true"
Expand Down
Expand Up @@ -220,7 +220,7 @@ exports[`defaults - snapshot 1`] = `
/>
<div
aria-hidden="true"
class=" emotion-9"
class="DropdownIndicatorContainer emotion-9"
>
<svg
aria-hidden="true"
Expand Down
Expand Up @@ -220,7 +220,7 @@ exports[`snapshot - defaults 1`] = `
/>
<div
aria-hidden="true"
class=" emotion-9"
class="DropdownIndicatorContainer emotion-9"
>
<svg
aria-hidden="true"
Expand Down
Expand Up @@ -220,7 +220,7 @@ exports[`defaults > snapshot 1`] = `
/>
<div
aria-hidden="true"
class=" emotion-9"
class="DropdownIndicatorContainer emotion-9"
>
<svg
aria-hidden="true"
Expand Down