Skip to content

Commit

Permalink
stopPropagation for mousedown and click in AnchoredOverlay (#1206)
Browse files Browse the repository at this point in the history
Co-authored-by: dgreif <dustin.greif@gmail.com>
  • Loading branch information
VanAnderson and dgreif committed May 5, 2021
1 parent c9b4db7 commit bba66fd
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/violet-geese-speak.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@primer/components": patch
---

stopPropagation for mousedown and click in AnchoredOverlay based components
6 changes: 6 additions & 0 deletions src/AnchoredOverlay/AnchoredOverlay.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ import {useFocusZone} from '../hooks/useFocusZone'
import {useAnchoredPosition, useRenderForcingRef} from '../hooks'
import {uniqueId} from '../utils/uniqueId'

function stopPropagation(event: React.UIEvent) {
event.stopPropagation()
}

export interface AnchoredOverlayProps {
/**
* A custom function component used to render the anchor element.
Expand Down Expand Up @@ -117,6 +121,8 @@ export const AnchoredOverlay: React.FC<AnchoredOverlayProps> = ({renderAnchor, c
ref={updateOverlayRef}
role="listbox"
visibility={position ? 'visible' : 'hidden'}
onMouseDown={stopPropagation}
onClick={stopPropagation}
{...overlayPosition}
>
{children}
Expand Down

0 comments on commit bba66fd

Please sign in to comment.