Skip to content

Commit ac0688b

Browse files
authored
Migrate AnchoredOverlay anchor ref
1 parent fc622c7 commit ac0688b

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

packages/react/src/ActionMenu/ActionMenu.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ const Overlay: FCWithSlotMarker<React.PropsWithChildren<MenuOverlayProps>> = ({
280280
// we typecast anchorRef as required instead of optional
281281
// because we know that we're setting it in context in Menu
282282
const {
283-
anchorRef,
283+
anchorRef: contextAnchorRef,
284284
renderAnchor,
285285
anchorId,
286286
open,
@@ -289,6 +289,9 @@ const Overlay: FCWithSlotMarker<React.PropsWithChildren<MenuOverlayProps>> = ({
289289
isSubmenu = false,
290290
} = React.useContext(MenuContext) as MandateProps<MenuContextProps, 'anchorRef'>
291291

292+
const anchorRef = useRef<HTMLElement>(null)
293+
const combinedAnchorRef = useCombinedRefs(anchorRef, contextAnchorRef)
294+
292295
const containerRef = React.useRef<HTMLDivElement>(null)
293296
const isNarrow = useResponsiveValue({narrow: true}, false)
294297

@@ -330,7 +333,7 @@ const Overlay: FCWithSlotMarker<React.PropsWithChildren<MenuOverlayProps>> = ({
330333

331334
return (
332335
<AnchoredOverlay
333-
anchorRef={anchorRef}
336+
anchorRef={combinedAnchorRef}
334337
renderAnchor={renderAnchor}
335338
anchorId={anchorId}
336339
open={open}

0 commit comments

Comments
 (0)