Skip to content

Commit

Permalink
fix: asset input bug
Browse files Browse the repository at this point in the history
  • Loading branch information
evilpeach committed May 27, 2024
1 parent 81c6b82 commit c707356
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Bug fixes

- [#944](https://github.com/alleslabs/celatone-frontend/pull/944) Fix asset input
- [#941](https://github.com/alleslabs/celatone-frontend/pull/941) Fix contract interaction routing
- [#936](https://github.com/alleslabs/celatone-frontend/pull/936) Fix mobile search not focusable
- [#931](https://github.com/alleslabs/celatone-frontend/pull/931) Fix minor module related ui
Expand Down
2 changes: 1 addition & 1 deletion src/lib/components/forms/AssetInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ interface AssetInputProps {
setCurrencyValue: (newVal: string) => void;
amountInput: JSX.Element;
assetOptions: AssetOptions[];
initialSelected: string;
initialSelected?: string;
labelBgColor?: string;
}

Expand Down
8 changes: 6 additions & 2 deletions src/lib/components/forms/SelectInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ interface SelectInputProps<T extends string> {
}[];
onChange: (newVal: T) => void;
placeholder?: string;
initialSelected: string;
initialSelected?: string;
hasDivider?: boolean;
helperTextComponent?: ReactNode;
labelBgColor?: string;
Expand Down Expand Up @@ -81,11 +81,14 @@ export const SelectInput = <T extends string>({
const selectedOption = options.find((item) => item.label === selected);

useEffect(() => {
if (initialSelected) return;

setSelected(
options.find((item) => !item.disabled && item.value === initialSelected)
?.label ?? ""
);
}, [initialSelected, options]);
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [initialSelected]);

return (
<Popover
Expand Down Expand Up @@ -162,6 +165,7 @@ export const SelectInput = <T extends string>({
borderBottomColor: hasDivider && "gray.700",
},
}}
overflow="scroll"
>
{options.map(({ label, value, disabled, icon, iconColor, image }) => (
<SelectItem
Expand Down
1 change: 0 additions & 1 deletion src/lib/components/fund/selectFund.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ export const SelectFund = ({
setValue(`${ASSETS_SELECT}.${idx}.denom`, newVal)
}
assetOptions={assetOptions}
initialSelected={field.denom}
labelBgColor={labelBgColor}
amountInput={
<ControllerInput
Expand Down

0 comments on commit c707356

Please sign in to comment.