Skip to content

Commit a28a79e

Browse files
committed
Change TextInput to only have onChange(string) for better UX
1 parent c72b80c commit a28a79e

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

src/components/TextInput.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,8 @@ const TextInput = forwardRef<TextInputRef, TextInputProps & Omit<React.InputHTML
8383
const handleInput = (e: React.ChangeEvent<HTMLInputElement>) => {
8484
if (onChange) {
8585
const newValue = textInputValue(useType, e.target.value)
86-
onChange(newValue)
86+
// Improve UX by always returning a string for text inputs
87+
onChange(typeof newValue == 'string' ? newValue : `${newValue ?? ''}`)
8788
}
8889
}
8990

src/components/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export interface TextInputProps {
2121
help?: string
2222
placeholder?: string
2323
value?: string|number
24-
onChange?: (value:string|number) => void
24+
onChange?: (value:string) => void
2525
}
2626
export interface TextInputRef {
2727
focus(): void

0 commit comments

Comments
 (0)