diff --git a/src/components/ButtonWithDropdownMenu/index.tsx b/src/components/ButtonWithDropdownMenu/index.tsx index dba5526d1c06..1fa40ad1b6ff 100644 --- a/src/components/ButtonWithDropdownMenu/index.tsx +++ b/src/components/ButtonWithDropdownMenu/index.tsx @@ -1,3 +1,4 @@ +import type {MutableRefObject} from 'react'; import React, {useEffect, useRef, useState} from 'react'; import {View} from 'react-native'; import Button from '@components/Button'; @@ -48,6 +49,7 @@ function ButtonWithDropdownMenu({ const selectedItem = options[selectedItemIndex] || options[0]; const innerStyleDropButton = StyleUtils.getDropDownButtonHeight(buttonSize); const isButtonSizeLarge = buttonSize === CONST.DROPDOWN_BUTTON_SIZE.LARGE; + const nullCheckRef = (ref: MutableRefObject) => ref ?? null; useEffect(() => { if (!dropdownAnchor.current) { @@ -149,7 +151,7 @@ function ButtonWithDropdownMenu({ onModalShow={onOptionsMenuShow} onItemSelected={() => setIsMenuVisible(false)} anchorPosition={popoverAnchorPosition} - anchorRef={dropdownAnchor} + anchorRef={nullCheckRef(dropdownAnchor)} withoutOverlay anchorAlignment={anchorAlignment} headerText={menuHeaderText}