Skip to content

Commit

Permalink
fix: virtual input value 0 (#6231)
Browse files Browse the repository at this point in the history
* fix: fix placeholder show when value is number 0 on virtual-input

* test: add value `0`

---------

Co-authored-by: wuguangsen.wgs <[email protected]>
Co-authored-by: miracles1919 <[email protected]>
  • Loading branch information
3 people authored Jul 10, 2023
1 parent 6337f96 commit 374e13d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions src/components/virtual-input/tests/virtual-input.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -108,4 +108,9 @@ describe('VirtualInput', () => {
).not.toBeVisible()
})
})

test('placeholder should not be shown when value is `0`', () => {
render(<VirtualInput value={0 as any} placeholder='placeholder' />)
expect(screen.queryByText('placeholder')).toBeNull()
})
})
2 changes: 1 addition & 1 deletion src/components/virtual-input/virtual-input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ export const VirtualInput = forwardRef<VirtualInputRef, VirtualInputProps>(
<CloseCircleFill />
</div>
)}
{!value && (
{[undefined, null, ''].includes(value) && (
<div className={`${classPrefix}-placeholder`}>
{props.placeholder}
</div>
Expand Down

0 comments on commit 374e13d

Please sign in to comment.