Skip to content

Commit 13562f4

Browse files
committed
Add autoSize property to Sender component
Fixes #635 --- For more details, open the [Copilot Workspace session](https://copilot-workspace.githubnext.com/ant-design/x/issues/635?shareId=XXXX-XXXX-XXXX-XXXX).
1 parent 2d8c45e commit 13562f4

File tree

4 files changed

+6
-1
lines changed

4 files changed

+6
-1
lines changed

components/sender/demo/basic.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ const Demo: React.FC = () => {
3838
setLoading(false);
3939
message.error('Cancel sending!');
4040
}}
41+
autoSize={{ minRows: 2, maxRows: 6 }}
4142
/>
4243
<Sender value="Force as loading" loading readOnly />
4344
<Sender disabled value="Set to disabled" />

components/sender/index.en-US.md

+1
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ Common props ref:[Common props](/docs/react/common-props)
5353
| onChange | Callback when input value changes | (value: string, event?: React.FormEvent<`HTMLTextAreaElement`> \| React.ChangeEvent<`HTMLTextAreaElement`> ) => void | - | - |
5454
| onCancel | Callback when click cancel button | () => void | - | - |
5555
| onPasteFile | Callback when paste files | (firstFile: File, files: FileList) => void | - | - |
56+
| autoSize | Height auto size feature, can be set to true \| false or an object { minRows: 2, maxRows: 6 } | { maxRows: 8 } | - |
5657

5758
```typescript | pure
5859
type SpeechConfig = {

components/sender/index.tsx

+3-1
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ export interface SenderProps
7474
allowSpeech?: AllowSpeech;
7575
prefix?: React.ReactNode;
7676
header?: React.ReactNode;
77+
autoSize?: boolean | { minRows?: number; maxRows?: number };
7778
}
7879

7980
export type SenderRef = {
@@ -114,6 +115,7 @@ const ForwardSender = React.forwardRef<SenderRef, SenderProps>((props, ref) => {
114115
header,
115116
onPaste,
116117
onPasteFile,
118+
autoSize = { maxRows: 8 },
117119
...rest
118120
} = props;
119121

@@ -308,7 +310,7 @@ const ForwardSender = React.forwardRef<SenderRef, SenderProps>((props, ref) => {
308310
disabled={disabled}
309311
style={{ ...contextConfig.styles.input, ...styles.input }}
310312
className={classnames(inputCls, contextConfig.classNames.input, classNames.input)}
311-
autoSize={{ maxRows: 8 }}
313+
autoSize={autoSize}
312314
value={innerValue}
313315
onChange={(event) => {
314316
triggerValueChange(

components/sender/index.zh-CN.md

+1
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ coverDark: https://mdn.alipayobjects.com/huamei_iwk9zp/afts/img/A*cOfrS4fVkOMAAA
5454
| onChange | 输入框值改变的回调 | (value: string, event?: React.FormEvent<`HTMLTextAreaElement`> \| React.ChangeEvent<`HTMLTextAreaElement`> ) => void | - | - |
5555
| onCancel | 点击取消按钮的回调 | () => void | - | - |
5656
| onPasteFile | 黏贴文件的回调 | (firstFile: File, files: FileList) => void | - | - |
57+
| autoSize | 自适应内容高度,可设置为 true \| false 或对象:{ minRows: 2, maxRows: 6 } | boolean \| { minRows?: number; maxRows?: number } | { maxRows: 8 } | - |
5758

5859
```typescript | pure
5960
type SpeechConfig = {

0 commit comments

Comments
 (0)