Skip to content

Commit c64801c

Browse files
committed
fix: use internal member to check if control onMouseDown should act
This is intended to be a temporal fix, as I think a better solution must be developed. Referenced issues: JedWatson#5833, JedWatson#5176 Another PRs abaout this: JedWatson#5842
1 parent 06e3488 commit c64801c

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

packages/react-select/src/Select.tsx

+7-2
Original file line numberDiff line numberDiff line change
@@ -657,6 +657,7 @@ export default class Select<
657657
scrollToFocusedOptionOnUpdate = false;
658658
userIsDragging?: boolean;
659659
isAppleDevice = isAppleDevice();
660+
mouseDownTriggeredBeyondControl = false;
660661

661662
// Refs
662663
// ------------------------------
@@ -1293,8 +1294,9 @@ export default class Select<
12931294
onControlMouseDown = (
12941295
event: React.MouseEvent<HTMLDivElement> | React.TouchEvent<HTMLDivElement>
12951296
) => {
1296-
// Event captured by dropdown indicator
1297-
if (event.defaultPrevented) {
1297+
// Event captured somewhere deeper in the DOM
1298+
if (this.mouseDownTriggeredBeyondControl) {
1299+
this.mouseDownTriggeredBeyondControl = false;
12981300
return;
12991301
}
13001302
const { openMenuOnClick } = this.props;
@@ -1342,6 +1344,7 @@ export default class Select<
13421344
} else {
13431345
this.openMenu('first');
13441346
}
1347+
this.mouseDownTriggeredBeyondControl = true;
13451348
event.preventDefault();
13461349
};
13471350
onClearIndicatorMouseDown = (
@@ -1356,6 +1359,7 @@ export default class Select<
13561359
return;
13571360
}
13581361
this.clearValue();
1362+
this.mouseDownTriggeredBeyondControl = true;
13591363
event.preventDefault();
13601364
this.openAfterFocus = false;
13611365
if (event.type === 'touchend') {
@@ -1835,6 +1839,7 @@ export default class Select<
18351839
onClick: () => this.removeValue(opt),
18361840
onTouchEnd: () => this.removeValue(opt),
18371841
onMouseDown: (e) => {
1842+
this.mouseDownTriggeredBeyondControl = true;
18381843
e.preventDefault();
18391844
},
18401845
}}

0 commit comments

Comments
 (0)