diff --git a/src/components/PopoverMenu.tsx b/src/components/PopoverMenu.tsx index cfc2c17ba8f4..149204d9351a 100644 --- a/src/components/PopoverMenu.tsx +++ b/src/components/PopoverMenu.tsx @@ -336,7 +336,7 @@ PopoverMenu.displayName = 'PopoverMenu'; export default React.memo( PopoverMenu, (prevProps, nextProps) => - lodashIsEqual(prevProps.menuItems, nextProps.menuItems) && + lodashIsEqual(prevProps.menuItems.length, nextProps.menuItems.length) && prevProps.isVisible === nextProps.isVisible && lodashIsEqual(prevProps.anchorPosition, nextProps.anchorPosition) && prevProps.anchorRef === nextProps.anchorRef && diff --git a/src/pages/home/report/ReportActionCompose/AttachmentPickerWithMenuItems.tsx b/src/pages/home/report/ReportActionCompose/AttachmentPickerWithMenuItems.tsx index 28d985537ff5..7da6a7aac2ee 100644 --- a/src/pages/home/report/ReportActionCompose/AttachmentPickerWithMenuItems.tsx +++ b/src/pages/home/report/ReportActionCompose/AttachmentPickerWithMenuItems.tsx @@ -213,6 +213,27 @@ function AttachmentPickerWithMenuItems({ setMenuVisibility(false); }, [didScreenBecomeInactive, isMenuVisible, setMenuVisibility]); + const getMenuItems = useCallback( + (triggerAttachmentPicker: () => void) => { + return [ + ...moneyRequestOptions, + ...taskOption, + { + icon: Expensicons.Paperclip, + text: translate('reportActionCompose.addAttachment'), + onSelected: () => { + if (Browser.isSafari()) { + return; + } + triggerAttachmentPicker(); + }, + shouldCallAfterModalHide: true, + }, + ]; + }, + [moneyRequestOptions, taskOption, translate], + ); + return ( {({openPicker}) => { @@ -223,21 +244,7 @@ function AttachmentPickerWithMenuItems({ onCanceled: onCanceledAttachmentPicker, }); }; - const menuItems = [ - ...moneyRequestOptions, - ...taskOption, - { - icon: Expensicons.Paperclip, - text: translate('reportActionCompose.addAttachment'), - onSelected: () => { - if (Browser.isSafari()) { - return; - } - triggerAttachmentPicker(); - }, - shouldCallAfterModalHide: true, - }, - ]; + const menuItems = getMenuItems(triggerAttachmentPicker); return ( <>