Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 21 additions & 5 deletions src/views/v3/Bridge/AssetPicker/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -292,15 +292,31 @@ function AssetPicker(props: Props) {
</Typography>
) : null;

const handleAmountChange = useCallback((newValue: string): void => {
setAmountInput(newValue);
setSelectedPercentButton(0); // Reset selected percent button when amount changes
}, []);
const handleAmountChange = useCallback(
(newValue: string): void => {
setAmountInput(newValue);
setSelectedPercentButton(0); // Reset selected percent button when amount changes

if (!newValue) {
// If the input is cleared, we need to clear the amount in handleAmountChange instead of handleDebouncedAmountChange.
// This case is important when user switches the token selection, which results in clearing the amount.
// If we do this in handleDebouncedAmountChange, it will get a new quote for the previous amount before clearing it
// and may cause the received amount to set to that quoted amount after user clears the input.
dispatch(setAmount(newValue));
}
},
[dispatch],
);

const handleDebouncedAmountChange = useCallback(
(newValue: string): void => {
dispatch(setAmount(newValue));
setDebouncedAmountInput(newValue);
if (newValue) {
// Only update the amount in the store if the input is not empty
// When the amount is cleared, it is handled in handleAmountChange
// Please see the comments in handleAmountChange for more details.
dispatch(setAmount(newValue));
}
},
[dispatch],
);
Expand Down
Loading