Skip to content

Commit 650f5bf

Browse files
committed
Fix input handleClear
1 parent 948d98b commit 650f5bf

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

.changeset/ten-apples-check.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@devup-ui/components': patch
3+
---
4+
5+
Fix input hadnClear

packages/components/src/components/Input/index.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ export function Input({
5050
disabled,
5151
className,
5252
classNames,
53+
readOnly,
5354
ref,
5455
onClear,
5556
...props
@@ -63,12 +64,16 @@ export function Input({
6364

6465
const handleClear = () => {
6566
setValue('')
67+
onChangeProp?.({
68+
target: { value: '' },
69+
} as React.ChangeEvent<HTMLInputElement>)
6670
onClear?.()
6771
}
6872

6973
const innerValue = valueProp ?? value
7074

71-
const clearButtonVisible = !!innerValue && !disabled && allowClear
75+
const clearButtonVisible =
76+
!!innerValue && !disabled && allowClear && !readOnly
7277

7378
return (
7479
<Box

0 commit comments

Comments
 (0)