From f4b8d07ec4c6bafd710ed027bd66bfa9fa3a7a8f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rui=20Sim=C3=A3o?= Date: Tue, 7 May 2024 10:18:09 +0100 Subject: [PATCH 1/2] fix(components): token input items --- .../components/src/TokenInput/TokenInput.tsx | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/packages/components/src/TokenInput/TokenInput.tsx b/packages/components/src/TokenInput/TokenInput.tsx index e07a382ca..288b3cb46 100644 --- a/packages/components/src/TokenInput/TokenInput.tsx +++ b/packages/components/src/TokenInput/TokenInput.tsx @@ -36,13 +36,26 @@ const TokenInput = forwardRef((props, ref): J const inputRef = useDOMRef(ref); - const defaultCurrency = useMemo(() => getDefaultCurrency(props), []); - const [value, setValue] = useState(defaultValue); + + const defaultCurrency = useMemo(() => getDefaultCurrency(props), []); const [currency, setCurrency] = useState(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; From ed11ff8fd8785ec809849d865422443e444c41b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sim=C3=A3o?= Date: Tue, 7 May 2024 10:24:16 +0100 Subject: [PATCH 2/2] Create purple-ants-suffer.md --- .changeset/purple-ants-suffer.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/purple-ants-suffer.md diff --git a/.changeset/purple-ants-suffer.md b/.changeset/purple-ants-suffer.md new file mode 100644 index 000000000..92e7c5f96 --- /dev/null +++ b/.changeset/purple-ants-suffer.md @@ -0,0 +1,5 @@ +--- +"@interlay/ui": patch +--- + +fix(components): token input items