Skip to content

Commit 53cc8ce

Browse files
committed
Use internal flag to skip duplicate event
1 parent 0664913 commit 53cc8ce

File tree

7 files changed

+10
-9
lines changed

7 files changed

+10
-9
lines changed

.changeset/allow-event-bubbling-for-all-controls.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
'react-select': patch
33
---
44

5-
Replace stopPropagation with target check.
5+
Use internal flag to prevent duplicate event handler for clicking select.

packages/react-select/src/Select.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -594,6 +594,7 @@ export default class Select<
594594
openAfterFocus = false;
595595
scrollToFocusedOptionOnUpdate = false;
596596
userIsDragging?: boolean;
597+
dropdownEventAlreadyHandled = false;
597598

598599
// Refs
599600
// ------------------------------
@@ -1157,8 +1158,8 @@ export default class Select<
11571158
event: React.MouseEvent<HTMLDivElement> | React.TouchEvent<HTMLDivElement>
11581159
) => {
11591160
// Event captured by dropdown indicator
1160-
// @ts-ignore
1161-
if (event.target.closest('.DropdownIndicatorContainer')) {
1161+
if (this.dropdownEventAlreadyHandled) {
1162+
this.dropdownEventAlreadyHandled = false;
11621163
return;
11631164
}
11641165
const { openMenuOnClick } = this.props;
@@ -1197,6 +1198,7 @@ export default class Select<
11971198
) {
11981199
return;
11991200
}
1201+
this.dropdownEventAlreadyHandled = true;
12001202
if (this.props.isDisabled) return;
12011203
const { isMulti, menuIsOpen } = this.props;
12021204
this.focusInput();
@@ -1780,7 +1782,6 @@ export default class Select<
17801782

17811783
return (
17821784
<DropdownIndicator
1783-
className="DropdownIndicatorContainer"
17841785
{...commonProps}
17851786
innerProps={innerProps}
17861787
isDisabled={isDisabled}

packages/react-select/src/__tests__/__snapshots__/Async.test.tsx.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ exports[`defaults - snapshot 1`] = `
220220
/>
221221
<div
222222
aria-hidden="true"
223-
class="DropdownIndicatorContainer emotion-9"
223+
class=" emotion-9"
224224
>
225225
<svg
226226
aria-hidden="true"

packages/react-select/src/__tests__/__snapshots__/AsyncCreatable.test.tsx.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ exports[`defaults - snapshot 1`] = `
220220
/>
221221
<div
222222
aria-hidden="true"
223-
class="DropdownIndicatorContainer emotion-9"
223+
class=" emotion-9"
224224
>
225225
<svg
226226
aria-hidden="true"

packages/react-select/src/__tests__/__snapshots__/Creatable.test.tsx.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ exports[`defaults - snapshot 1`] = `
220220
/>
221221
<div
222222
aria-hidden="true"
223-
class="DropdownIndicatorContainer emotion-9"
223+
class=" emotion-9"
224224
>
225225
<svg
226226
aria-hidden="true"

packages/react-select/src/__tests__/__snapshots__/Select.test.tsx.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ exports[`snapshot - defaults 1`] = `
220220
/>
221221
<div
222222
aria-hidden="true"
223-
class="DropdownIndicatorContainer emotion-9"
223+
class=" emotion-9"
224224
>
225225
<svg
226226
aria-hidden="true"

packages/react-select/src/__tests__/__snapshots__/StateManaged.test.tsx.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ exports[`defaults > snapshot 1`] = `
220220
/>
221221
<div
222222
aria-hidden="true"
223-
class="DropdownIndicatorContainer emotion-9"
223+
class=" emotion-9"
224224
>
225225
<svg
226226
aria-hidden="true"

0 commit comments

Comments
 (0)