Skip to content

Commit

Permalink
fix(components): token input items (#97)
Browse files Browse the repository at this point in the history
  • Loading branch information
danielsimao authored May 7, 2024
1 parent f91d6a3 commit 459f4aa
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/purple-ants-suffer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@interlay/ui": patch
---

fix(components): token input items
17 changes: 15 additions & 2 deletions packages/components/src/TokenInput/TokenInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,26 @@ const TokenInput = forwardRef<HTMLInputElement, TokenInputProps>((props, ref): J

const inputRef = useDOMRef<HTMLInputElement>(ref);

const defaultCurrency = useMemo(() => getDefaultCurrency(props), []);

const [value, setValue] = useState(defaultValue);

const defaultCurrency = useMemo(() => getDefaultCurrency(props), []);
const [currency, setCurrency] = useState<any | undefined>(defaultCurrency);

const inputId = useId();

useEffect(
() => {
if (props.type === 'selectable') {
setCurrency(
(props.items || []).find(
(item) => item.currency.symbol === (props.selectProps?.value || props.selectProps?.defaultValue)
)?.currency
);
}
},
props.type === 'selectable' ? [props.items] : []
);

useEffect(() => {
if (valueProp === undefined) return;

Expand Down

0 comments on commit 459f4aa

Please sign in to comment.