From dd6ab9f6b901dbc68303ea8f81896d6bd7304773 Mon Sep 17 00:00:00 2001 From: "wuguangsen.wgs" Date: Tue, 4 Jul 2023 14:23:45 +0800 Subject: [PATCH 1/2] fix: fix placeholder show when value is number 0 on virtual-input --- src/components/virtual-input/virtual-input.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/virtual-input/virtual-input.tsx b/src/components/virtual-input/virtual-input.tsx index 6e764320b9..11751f9fc0 100644 --- a/src/components/virtual-input/virtual-input.tsx +++ b/src/components/virtual-input/virtual-input.tsx @@ -151,7 +151,7 @@ export const VirtualInput = forwardRef( )} - {!value && ( + {[undefined, null, ''].includes(value) && (
{props.placeholder}
From 8de134d555fd2ea9ad2c3abd2cef5104ef64c66a Mon Sep 17 00:00:00 2001 From: miracles1919 <516571350@qq.com> Date: Fri, 7 Jul 2023 22:35:18 +0800 Subject: [PATCH 2/2] test: add value `0` --- src/components/virtual-input/tests/virtual-input.test.tsx | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/components/virtual-input/tests/virtual-input.test.tsx b/src/components/virtual-input/tests/virtual-input.test.tsx index 5e12b35674..0cd11daab9 100644 --- a/src/components/virtual-input/tests/virtual-input.test.tsx +++ b/src/components/virtual-input/tests/virtual-input.test.tsx @@ -108,4 +108,9 @@ describe('VirtualInput', () => { ).not.toBeVisible() }) }) + + test('placeholder should not be shown when value is `0`', () => { + render() + expect(screen.queryByText('placeholder')).toBeNull() + }) })