From f3609587a723ae4d845f5c1a66af3e5c00bfbd88 Mon Sep 17 00:00:00 2001 From: liweijie0812 <674416404@qq.com> Date: Fri, 23 Aug 2024 13:50:39 +0800 Subject: [PATCH] fix(rate): resolve displayTexts empty (#3060) * fix(rate): resolve displayTexts empty * chore: update snapshot --------- Co-authored-by: github-actions[bot] --- src/rate/Rate.tsx | 2 +- test/snap/__snapshots__/csr.test.jsx.snap | 6 ++++-- test/snap/__snapshots__/ssr.test.jsx.snap | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/rate/Rate.tsx b/src/rate/Rate.tsx index 3e3a36eb14..50be96cf8f 100644 --- a/src/rate/Rate.tsx +++ b/src/rate/Rate.tsx @@ -36,7 +36,7 @@ const Rate = React.forwardRef((originalProps, ref) => const { allowHalf, color, count, disabled, gap, showText, size, icon, className, style, onChange, texts } = props; const [locale, t] = useLocaleReceiver('rate'); - const displayTexts = texts || t(locale.rateText); + const displayTexts = texts.length ? texts : t(locale.rateText); const { classPrefix } = useConfig(); const [starValue = 0, setStarValue] = useControlled(props, 'value', onChange); diff --git a/test/snap/__snapshots__/csr.test.jsx.snap b/test/snap/__snapshots__/csr.test.jsx.snap index 9e63e24a63..7431269f60 100644 --- a/test/snap/__snapshots__/csr.test.jsx.snap +++ b/test/snap/__snapshots__/csr.test.jsx.snap @@ -72962,7 +72962,9 @@ exports[`csr snapshot test > csr test src/rate/_example/texts.tsx 1`] = `
+ > + satisfied +
`; @@ -133809,7 +133811,7 @@ exports[`ssr snapshot test > ssr test src/rate/_example/size.tsx 1`] = `"
ssr test src/rate/_example/status.tsx 1`] = `"

未评分状态

满分状态

半星状态

"`; -exports[`ssr snapshot test > ssr test src/rate/_example/texts.tsx 1`] = `"
"`; +exports[`ssr snapshot test > ssr test src/rate/_example/texts.tsx 1`] = `"
satisfied
"`; exports[`ssr snapshot test > ssr test src/select/_example/base.tsx 1`] = `"
"`; diff --git a/test/snap/__snapshots__/ssr.test.jsx.snap b/test/snap/__snapshots__/ssr.test.jsx.snap index 46dfc2bbec..5ab5e4bd19 100644 --- a/test/snap/__snapshots__/ssr.test.jsx.snap +++ b/test/snap/__snapshots__/ssr.test.jsx.snap @@ -760,7 +760,7 @@ exports[`ssr snapshot test > ssr test src/rate/_example/size.tsx 1`] = `"
ssr test src/rate/_example/status.tsx 1`] = `"

未评分状态

满分状态

半星状态

"`; -exports[`ssr snapshot test > ssr test src/rate/_example/texts.tsx 1`] = `"
"`; +exports[`ssr snapshot test > ssr test src/rate/_example/texts.tsx 1`] = `"
satisfied
"`; exports[`ssr snapshot test > ssr test src/select/_example/base.tsx 1`] = `"
"`;