From 021745f1abb50745b62b7aeeb53ca5bc34967ca2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BA=8C=E8=B4=A7=E7=88=B1=E5=90=83=E7=99=BD=E8=90=9D?= =?UTF-8?q?=E5=8D=9C?= Date: Wed, 13 Nov 2024 11:12:39 +0800 Subject: [PATCH] fix: Safari Badge scroll number missing (#51598) * fix: Safari Badge scroll number missing * test: update snapshot --- components/badge/SingleNumber.tsx | 12 +- .../__snapshots__/index.test.tsx.snap | 163 ------------------ 2 files changed, 9 insertions(+), 166 deletions(-) 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 -