Skip to content

Commit

Permalink
feat: support onClear callback
Browse files Browse the repository at this point in the history
  • Loading branch information
li-jia-nan committed Jul 16, 2024
1 parent c18cc42 commit 0dbf4e0
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/Input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ const Input = forwardRef<InputRef, InputProps>((props, ref) => {
styles,
onCompositionStart,
onCompositionEnd,
onClear,
...rest
} = props;

Expand Down Expand Up @@ -173,6 +174,7 @@ const Input = forwardRef<InputRef, InputProps>((props, ref) => {
const handleReset = (e: React.MouseEvent<HTMLElement, MouseEvent>) => {
setValue('');
focus();
onClear?.();
if (inputRef.current) {
resolveOnChange(inputRef.current, e, onChange);
}
Expand Down
1 change: 1 addition & 0 deletions src/interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ export interface InputProps
count?: CSSProperties;
};
count?: CountConfig;
onClear?: () => void;
}

export interface InputRef {
Expand Down

0 comments on commit 0dbf4e0

Please sign in to comment.