Skip to content

Commit

Permalink
fix: select token modal list style (#1382)
Browse files Browse the repository at this point in the history
  • Loading branch information
danielsimao authored Jun 29, 2023
1 parent 0c40d3e commit b296507
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
6 changes: 3 additions & 3 deletions src/component-library/TokenInput/TokenListItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ import { Span } from '../Text';
import { StyledListItemLabel, StyledListTokenWrapper } from './TokenInput.style';
import { TokenData } from './TokenSelect';

type TokenListItemProps = TokenData;
type TokenListItemProps = { isDisabled?: boolean } & TokenData;

const TokenListItem = ({ balance, balanceUSD, value, tickers }: TokenListItemProps): JSX.Element => {
const isSelected = useSelectModalContext().selectedItem?.key === value;
const TokenListItem = ({ balance, balanceUSD, value, tickers, isDisabled }: TokenListItemProps): JSX.Element => {
const isSelected = useSelectModalContext().selectedItem?.key === value && !isDisabled;

return (
<>
Expand Down
10 changes: 8 additions & 2 deletions src/components/TransactionDetails/TransactionSelectToken.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ const TransactionSelectToken = ({
label: labelProp,
tooltipLabel,
items,
value,
...props
}: TransactionSelectTokenProps): JSX.Element => {
const { t } = useTranslation();
Expand All @@ -35,7 +36,11 @@ const TransactionSelectToken = ({
labelProp
);

const disabledKeys = (items as TokenData[])?.filter((item) => Number(item.balance) === 0).map((item) => item.value);
// disabled zero balance currencies ignoring the current value
// even if the balance is zero
const disabledKeys = (items as TokenData[])
?.filter((item) => Number(item.balance) === 0 && item.value !== value)
.map((item) => item.value);

return (
<StyledSelect
Expand All @@ -46,11 +51,12 @@ const TransactionSelectToken = ({
disabledKeys={disabledKeys}
label={label}
items={items}
value={value}
{...props}
>
{(data: TokenData) => (
<Item key={data.value} textValue={data.value}>
<TokenListItem {...data} />
<TokenListItem {...data} isDisabled={disabledKeys.includes(data.value)} />
</Item>
)}
</StyledSelect>
Expand Down

2 comments on commit b296507

@vercel
Copy link

@vercel vercel bot commented on b296507 Jun 29, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vercel
Copy link

@vercel vercel bot commented on b296507 Jun 29, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.