Skip to content

Commit 12d88da

Browse files
committed
update modal to popover menu
1 parent e024a68 commit 12d88da

1 file changed

Lines changed: 25 additions & 17 deletions

File tree

src/pages/Search/SearchSelectedNarrow.tsx

Lines changed: 25 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@ import React, {useRef, useState} from 'react';
22
import {View} from 'react-native';
33
import Button from '@components/Button';
44
import type {DropdownOption} from '@components/ButtonWithDropdownMenu/types';
5-
import MenuItem from '@components/MenuItem';
6-
import Modal from '@components/Modal';
5+
import PopoverMenu from '@components/PopoverMenu';
76
import type {SearchHeaderOptionValue} from '@components/Search/SearchPageHeader/SearchPageHeader';
87
import useLocalize from '@hooks/useLocalize';
98
import useThemeStyles from '@hooks/useThemeStyles';
@@ -58,24 +57,33 @@ function SearchSelectedNarrow({options, itemsLength}: SearchSelectedNarrowProps)
5857
shouldShowRightIcon={options.length !== 0}
5958
success
6059
/>
61-
<Modal
60+
<PopoverMenu
6261
isVisible={isModalVisible}
63-
type={CONST.MODAL.MODAL_TYPE.BOTTOM_DOCKED}
6462
onClose={handleOnCloseMenu}
6563
onModalHide={handleOnModalHide}
66-
>
67-
{options.map((option, index) => (
68-
<MenuItem
69-
// eslint-disable-next-line react/jsx-props-no-spreading
70-
{...option}
71-
title={option.text}
72-
titleStyle={option.titleStyle}
73-
icon={option.icon}
74-
onPress={() => handleOnMenuItemPress(option, index)}
75-
key={option.value}
76-
/>
77-
))}
78-
</Modal>
64+
onItemSelected={(selectedItem, index) => {
65+
handleOnMenuItemPress(selectedItem as DropdownOption<SearchHeaderOptionValue>, index);
66+
}}
67+
anchorPosition={{horizontal: 0, vertical: 0}}
68+
anchorRef={buttonRef}
69+
anchorAlignment={{
70+
horizontal: CONST.MODAL.ANCHOR_ORIGIN_HORIZONTAL.LEFT,
71+
vertical: CONST.MODAL.ANCHOR_ORIGIN_VERTICAL.BOTTOM,
72+
}}
73+
fromSidebarMediumScreen={false}
74+
shouldUseModalPaddingStyle
75+
menuItems={options.map((item, index) => ({
76+
...item,
77+
onSelected: item.onSelected
78+
? () => {
79+
item.onSelected?.();
80+
}
81+
: () => {
82+
handleOnMenuItemPress(item, index);
83+
},
84+
shouldCallAfterModalHide: true,
85+
}))}
86+
/>
7987
</View>
8088
);
8189
}

0 commit comments

Comments
 (0)