Skip to content

Commit

Permalink
fix: range slider decimals issue
Browse files Browse the repository at this point in the history
  • Loading branch information
naturexie committed Jan 17, 2025
1 parent 992ab37 commit 47d0ec6
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
6 changes: 3 additions & 3 deletions components/Modal/Controls.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,22 +23,22 @@ export default function Controls({ amount, available, action, asset, totalAvaila
dispatch(updateAmount({ isMax: false, amount: value }));
}
};

const handleSliderChange = (percent) => {
const p = percent < 1 ? 0 : percent > 99 ? 100 : percent;
const value = new Decimal(available).mul(p).div(100).toFixed();
const decimalLength = value?.split(".")?.[1]?.length || 0;
if (isMeme) {
dispatch(
updateAmountMEME({
isMax: p === 100,
amount: new Decimal(value || 0).toFixed(),
amount: new Decimal(value || 0).toFixed(Math.min(decimalLength, asset.decimals)),
}),
);
} else {
dispatch(
updateAmount({
isMax: p === 100,
amount: new Decimal(value || 0).toFixed(),
amount: new Decimal(value || 0).toFixed(Math.min(decimalLength, asset.decimals)),
}),
);
}
Expand Down
1 change: 0 additions & 1 deletion components/Modal/RangeSlider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ export default function RangeSlider(props: any) {
function changeValue(v: string, isClickValue?: boolean) {
let matchedValue;
const numValue = Number(v);
// const toPercent = (100 / splitList.length) * numValue;
if (isClickValue) {
matchedValue = numValue;
if (isMonth) {
Expand Down

0 comments on commit 47d0ec6

Please sign in to comment.