Skip to content

Commit

Permalink
refactor(suite): rename menuIsOpen to isMenuOpen
Browse files Browse the repository at this point in the history
  • Loading branch information
adderpositive authored and tomasklim committed Oct 1, 2024
1 parent 01c60f3 commit 5288cb9
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export const Select: StoryObj<SelectProps> = {
hasBottomPadding: true,
size: 'large',
minValueWidth: 'initial',
menuIsOpen: undefined,
isMenuOpen: undefined,
useKeyPressScroll: undefined,
},
argTypes: {
Expand Down Expand Up @@ -80,7 +80,7 @@ export const Select: StoryObj<SelectProps> = {
minValueWidth: {
control: { type: 'text' },
},
menuIsOpen: {
isMenuOpen: {
control: {
type: 'boolean',
},
Expand Down
15 changes: 8 additions & 7 deletions packages/components/src/components/form/Select/Select.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ const createSelectStyle = (
type WrapperProps = TransientProps<
Pick<
SelectProps,
'isClean' | 'isDisabled' | 'minValueWidth' | 'size' | 'menuIsOpen' | 'isSearchable'
'isClean' | 'isDisabled' | 'minValueWidth' | 'size' | 'isMenuOpen' | 'isSearchable'
>
> & {
$isWithLabel: boolean;
Expand Down Expand Up @@ -250,7 +250,7 @@ const closeMenuOnScroll = (e: Event) =>

export type Option = any;

interface CommonProps extends Omit<ReactSelectProps<Option>, 'onChange'> {
interface CommonProps extends Omit<ReactSelectProps<Option>, 'onChange' | 'menuIsOpen'> {
isClean?: boolean;
label?: ReactNode;
size?: InputSize;
Expand All @@ -261,6 +261,7 @@ interface CommonProps extends Omit<ReactSelectProps<Option>, 'onChange'> {
hasBottomPadding?: boolean;
minValueWidth?: string; // TODO: should be probably removed
inputState?: InputState;
isMenuOpen?: boolean;
onChange?: (value: Option, ref?: SelectInstance<Option, boolean> | null) => void;
'data-testid'?: string;
}
Expand All @@ -283,7 +284,7 @@ export const Select = ({
useKeyPressScroll,
isSearchable = false,
minValueWidth = 'initial',
menuIsOpen,
isMenuOpen,
inputState,
components,
onChange,
Expand All @@ -305,14 +306,14 @@ export const Select = ({
if (value) {
onChange?.(value, selectRef.current);

if (!menuIsOpen && action === 'select-option') {
if (!isMenuOpen && action === 'select-option') {
selectRef.current?.blur();
}
}

return null;
},
[onChange, menuIsOpen],
[onChange, isMenuOpen],
);

/**
Expand Down Expand Up @@ -343,7 +344,7 @@ export const Select = ({
$size={size}
$minValueWidth={minValueWidth}
$isDisabled={isDisabled}
$menuIsOpen={menuIsOpen}
$isMenuOpen={isMenuOpen}
$isWithLabel={!!label}
$isWithPlaceholder={!!placeholder}
$hasBottomPadding={hasBottomPadding === true && bottomText === null}
Expand All @@ -359,7 +360,7 @@ export const Select = ({
styles={createSelectStyle(theme, elevation, isRenderedInModal)}
onChange={handleOnChange}
isSearchable={isSearchable}
menuIsOpen={menuIsOpen}
menuIsOpen={isMenuOpen}
isDisabled={isDisabled}
menuPlacement="auto"
placeholder={placeholder || ''}
Expand Down
2 changes: 1 addition & 1 deletion packages/suite/src/components/suite/WordInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export const WordInput = memo(() => {
autoFocus
isSearchable
isClearable={false}
menuIsOpen
isMenuOpen
noOptionsMessage={({ inputValue }: { inputValue: string }) =>
translationString('TR_WORD_DOES_NOT_EXIST', { word: inputValue })
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ export const CoinmarketFormInputCryptoSelect = <
}}
data-testid="@coinmarket/form/select-crypto"
isClearable={false}
menuIsOpen={false}
isMenuOpen={false}
/>
)}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export const CoinmarketVerifyOptions = ({
formatOptionLabel={option => (
<CoinmarketVerifyOptionsItem option={option} receiveNetwork={receiveNetwork} />
)}
menuIsOpen={isMenuOpen}
isMenuOpen={isMenuOpen}
isDisabled={selectAccountOptions.length === 1}
placeholder={
<Translation
Expand Down

0 comments on commit 5288cb9

Please sign in to comment.