Skip to content

Commit bba66fd

Browse files
VanAndersondgreif
andauthored
stopPropagation for mousedown and click in AnchoredOverlay (#1206)
Co-authored-by: dgreif <dustin.greif@gmail.com>
1 parent c9b4db7 commit bba66fd

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

.changeset/violet-geese-speak.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@primer/components": patch
3+
---
4+
5+
stopPropagation for mousedown and click in AnchoredOverlay based components

src/AnchoredOverlay/AnchoredOverlay.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ import {useFocusZone} from '../hooks/useFocusZone'
55
import {useAnchoredPosition, useRenderForcingRef} from '../hooks'
66
import {uniqueId} from '../utils/uniqueId'
77

8+
function stopPropagation(event: React.UIEvent) {
9+
event.stopPropagation()
10+
}
11+
812
export interface AnchoredOverlayProps {
913
/**
1014
* A custom function component used to render the anchor element.
@@ -117,6 +121,8 @@ export const AnchoredOverlay: React.FC<AnchoredOverlayProps> = ({renderAnchor, c
117121
ref={updateOverlayRef}
118122
role="listbox"
119123
visibility={position ? 'visible' : 'hidden'}
124+
onMouseDown={stopPropagation}
125+
onClick={stopPropagation}
120126
{...overlayPosition}
121127
>
122128
{children}

0 commit comments

Comments
 (0)