Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
"dependencies": {
"@babel/runtime": "^7.10.1",
"classnames": "^2.2.1",
"rc-input": "~1.5.0",
"rc-input": "~1.6.0",
"rc-resize-observer": "^1.0.0",
"rc-util": "^5.27.0"
},
Expand Down
1 change: 0 additions & 1 deletion src/ResizableTextArea.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ const ResizableTextArea = React.forwardRef<ResizableTextAreaRef, TextAreaProps>(
(props, ref) => {
const {
prefixCls,
onPressEnter,
defaultValue,
value,
autoSize,
Expand Down
2 changes: 2 additions & 0 deletions src/TextArea.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ const TextArea = React.forwardRef<TextAreaRef, TextAreaProps>(
classNames,
styles,
onResize,
onClear,
readOnly,
...rest
},
Expand Down Expand Up @@ -238,6 +239,7 @@ const TextArea = React.forwardRef<TextAreaRef, TextAreaProps>(
}}
hidden={hidden}
readOnly={readOnly}
onClear={onClear}
>
<ResizableTextArea
{...rest}
Expand Down
2 changes: 1 addition & 1 deletion src/interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export type TextAreaProps = Omit<HTMLTextareaProps, 'onResize' | 'value'> & {
count?: CSSProperties;
};
} & Pick<BaseInputProps, 'allowClear' | 'suffix'> &
Pick<InputProps, 'showCount' | 'count'>;
Pick<InputProps, 'showCount' | 'count' | 'onClear'>;

export type TextAreaRef = {
resizableTextArea: ResizableTextAreaRef;
Expand Down
11 changes: 11 additions & 0 deletions tests/allowClear.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -128,3 +128,14 @@ it('should not textarea clear className', () => {
container.querySelector('.rc-textarea-textarea-allow-clear'),
).toBeFalsy();
});

it('support onClear', () => {
const onClear = jest.fn();
const { container } = render(
<TextArea onClear={onClear} defaultValue="test" allowClear />,
);
fireEvent.click(
container.querySelector<HTMLSpanElement>('.rc-textarea-clear-icon')!,
);
expect(onClear).toHaveBeenCalled();
});