Skip to content

Commit

Permalink
fix(suite-native): Close sheet on select (#6535)
Browse files Browse the repository at this point in the history
  • Loading branch information
juriczech authored Oct 12, 2022
1 parent f44f215 commit d098d16
Showing 1 changed file with 14 additions and 15 deletions.
29 changes: 14 additions & 15 deletions suite-native/atoms/src/Select/Select.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ export const Select = <TItemValue extends SelectItemValue>({
);
const handleSelectItem = (itemValue: TItemValue) => {
onSelectItem(itemValue);
setIsOpen(false);
};

const getIcon = (iconName?: CryptoIconName | FlagIconName, isSelectItem = false): ReactNode => {
Expand All @@ -60,21 +61,19 @@ export const Select = <TItemValue extends SelectItemValue>({

return (
<>
{isOpen && (
<BottomSheet isVisible={isOpen} onVisibilityChange={setIsOpen} title={selectLabel}>
{items.map(({ value, label, iconName }, index) => (
<SelectItem
key={value}
label={label}
value={value}
icon={getIcon(iconName, true)}
isSelected={value === selectedItem?.value}
isLastChild={index === items.length - 1}
onSelect={() => handleSelectItem(value)}
/>
))}
</BottomSheet>
)}
<BottomSheet isVisible={isOpen} onVisibilityChange={setIsOpen} title={selectLabel}>
{items.map(({ value, label, iconName }, index) => (
<SelectItem
key={value}
label={label}
value={value}
icon={getIcon(iconName, true)}
isSelected={value === selectedItem?.value}
isLastChild={index === items.length - 1}
onSelect={() => handleSelectItem(value)}
/>
))}
</BottomSheet>
<SelectTrigger
icon={getIcon(selectedItem?.iconName)}
value={selectedItem?.label ?? null}
Expand Down

0 comments on commit d098d16

Please sign in to comment.