diff --git a/components/badge/SingleNumber.tsx b/components/badge/SingleNumber.tsx index 829569c74e..d4dd03ea9b 100644 --- a/components/badge/SingleNumber.tsx +++ b/components/badge/SingleNumber.tsx @@ -79,23 +79,29 @@ const SingleNumber: React.FC> = (props) => { unitNumberList.push(index); } + const unit = prevCount < count ? 1 : -1; + // Fill with number unit nodes const prevIndex = unitNumberList.findIndex((n) => n % 10 === prevValue); - unitNodes = unitNumberList.map((n, index) => { + + // Cut list + const cutUnitNumberList = + unit < 0 ? unitNumberList.slice(0, prevIndex + 1) : unitNumberList.slice(prevIndex); + + unitNodes = cutUnitNumberList.map((n, index) => { const singleUnit = n % 10; return ( ); }); // Calculate container offset value - const unit = prevCount < count ? 1 : -1; offsetStyle = { transform: `translateY(${-getOffset(prevValue, value, unit)}00%)`, }; diff --git a/components/badge/__tests__/__snapshots__/index.test.tsx.snap b/components/badge/__tests__/__snapshots__/index.test.tsx.snap index ca44c0f66b..9dfd55be1e 100644 --- a/components/badge/__tests__/__snapshots__/index.test.tsx.snap +++ b/components/badge/__tests__/__snapshots__/index.test.tsx.snap @@ -305,60 +305,6 @@ exports[`Badge should render when count is changed 1`] = ` > - 0 - - - 1 - - - 2 - - - 3 - - - 4 - - - 5 - - - 6 - - - 7 - - - 8 - - 9 @@ -400,60 +346,6 @@ exports[`Badge should render when count is changed 2`] = ` > - 1 - - - 2 - - - 3 - - - 4 - - - 5 - - - 6 - - - 7 - - - 8 - - - 9 - - 0 @@ -495,7 +387,6 @@ exports[`Badge should render when count is changed 3`] = ` > 1 @@ -579,60 +470,6 @@ exports[`Badge should render when count is changed 6`] = ` > 0 - - 1 - - - 2 - - - 3 - - - 4 - - - 5 - - - 6 - - - 7 - - - 8 - - - 9 -