Skip to content

Commit a44c769

Browse files
authored
Don't text select after dismissing a dialog in FF (adobe#1187)
* Don't text select after dismissing a dialog in FF
1 parent 4b3b282 commit a44c769

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

packages/@react-aria/interactions/src/useInteractOutside.ts

+14
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,11 @@ export function useInteractOutside(props: InteractOutsideProps) {
3838
let onPointerDown = (e) => {
3939
if (isValidEvent(e, ref)) {
4040
state.isPointerDown = true;
41+
// Due to browser inconsistencies, we prevent
42+
// default on pointer down. FF will otherwise try to start text selection.
43+
if (e.button === 0) {
44+
e.preventDefault();
45+
}
4146
}
4247
};
4348

@@ -47,6 +52,9 @@ export function useInteractOutside(props: InteractOutsideProps) {
4752
if (state.isPointerDown && onInteractOutside && isValidEvent(e, ref)) {
4853
state.isPointerDown = false;
4954
onInteractOutside(e);
55+
if (e.button === 0) {
56+
e.preventDefault();
57+
}
5058
}
5159
};
5260

@@ -65,6 +73,9 @@ export function useInteractOutside(props: InteractOutsideProps) {
6573
} else if (state.isPointerDown && onInteractOutside && isValidEvent(e, ref)) {
6674
state.isPointerDown = false;
6775
onInteractOutside(e);
76+
if (e.button === 0) {
77+
e.preventDefault();
78+
}
6879
}
6980
};
7081

@@ -73,6 +84,9 @@ export function useInteractOutside(props: InteractOutsideProps) {
7384
if (onInteractOutside && state.isPointerDown && isValidEvent(e, ref)) {
7485
state.isPointerDown = false;
7586
onInteractOutside(e);
87+
if (e.button === 0) {
88+
e.preventDefault();
89+
}
7690
}
7791
};
7892

0 commit comments

Comments
 (0)