Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Mentions support autoSize #24961

Merged
merged 1 commit into from Jun 12, 2020
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions components/input/__tests__/__snapshots__/demo.test.js.snap
Expand Up @@ -252,6 +252,7 @@ Array [
style="width:100px"
>
<textarea
class="rc-textarea"
rows="1"
/>
</div>,
Expand Down
20 changes: 20 additions & 0 deletions components/mentions/__tests__/__snapshots__/demo.test.js.snap
Expand Up @@ -6,6 +6,19 @@ exports[`renders ./components/mentions/demo/async.md correctly 1`] = `
style="width:100%"
>
<textarea
class="rc-textarea"
rows="1"
/>
</div>
`;

exports[`renders ./components/mentions/demo/autoSize.md correctly 1`] = `
<div
class="ant-mentions"
style="width:100%"
>
<textarea
class="rc-textarea"
rows="1"
/>
</div>
Expand All @@ -17,6 +30,7 @@ exports[`renders ./components/mentions/demo/basic.md correctly 1`] = `
style="width:100%"
>
<textarea
class="rc-textarea"
rows="1"
>
@afc163
Expand Down Expand Up @@ -55,6 +69,7 @@ exports[`renders ./components/mentions/demo/form.md correctly 1`] = `
class="ant-mentions"
>
<textarea
class="rc-textarea"
id="coders"
rows="1"
/>
Expand Down Expand Up @@ -90,6 +105,7 @@ exports[`renders ./components/mentions/demo/form.md correctly 1`] = `
class="ant-mentions"
>
<textarea
class="rc-textarea"
id="bio"
placeholder="You can use @ to ref user here"
rows="3"
Expand Down Expand Up @@ -141,6 +157,7 @@ exports[`renders ./components/mentions/demo/placement.md correctly 1`] = `
style="width:100%"
>
<textarea
class="rc-textarea"
rows="1"
/>
</div>
Expand All @@ -152,6 +169,7 @@ exports[`renders ./components/mentions/demo/prefix.md correctly 1`] = `
style="width:100%"
>
<textarea
class="rc-textarea"
placeholder="input @ to mention people, # to mention tag"
rows="1"
/>
Expand All @@ -168,6 +186,7 @@ exports[`renders ./components/mentions/demo/readonly.md correctly 1`] = `
style="width:100%"
>
<textarea
class="rc-textarea rc-textarea-disabled"
disabled=""
placeholder="this is disabled Mentions"
rows="1"
Expand All @@ -179,6 +198,7 @@ exports[`renders ./components/mentions/demo/readonly.md correctly 1`] = `
style="width:100%"
>
<textarea
class="rc-textarea"
placeholder="this is readOnly Mentions"
readonly=""
rows="1"
Expand Down
Expand Up @@ -5,6 +5,7 @@ exports[`Mentions rtl render component should be rendered correctly in RTL direc
class="ant-mentions ant-mentions-rtl"
>
<textarea
class="rc-textarea"
rows="1"
/>
</div>
Expand Down
29 changes: 29 additions & 0 deletions components/mentions/demo/autoSize.md
@@ -0,0 +1,29 @@
---
order: 6
title:
zh-CN: 自动大小
en-US: autoSize
---

## zh-CN

自适应内容高度。

## en-US

Height autoSize.

```jsx
import { Mentions } from 'antd';

const { Option } = Mentions;

ReactDOM.render(
<Mentions autoSize style={{ width: '100%' }}>
<Option value="afc163">afc163</Option>
<Option value="zombieJ">zombieJ</Option>
<Option value="yesmeck">yesmeck</Option>
</Mentions>,
mountNode,
);
```
2 changes: 1 addition & 1 deletion components/mentions/demo/basic.md
Expand Up @@ -7,7 +7,7 @@ title:

## zh-CN

基本使用
基本使用

## en-US

Expand Down
2 changes: 2 additions & 0 deletions components/mentions/index.en-US.md
Expand Up @@ -38,6 +38,8 @@ When need to mention someone or something.
| onFocus | Trigger when mentions get focus | () => void | |
| onBlur | Trigger when mentions lose focus | () => void | |
| getPopupContainer | Set the mount HTML node for suggestions | () => HTMLElement | |
| autoSize | Textarea height autosize feature, can be set to `true\|false` or an object `{ minRows: 2, maxRows: 6 }` | boolean \| object | false |
| onResize | The callback function that is triggered when textarea resize | function({ width, height }) | |

### Mention methods

Expand Down
2 changes: 2 additions & 0 deletions components/mentions/index.zh-CN.md
Expand Up @@ -39,6 +39,8 @@ cover: https://gw.alipayobjects.com/zos/alicdn/jPE-itMFM/Mentions.svg
| onFocus | 获得焦点时触发 | () => void | |
| onBlur | 失去焦点时触发 | () => void | |
| getPopupContainer | 指定建议框挂载的 HTML 节点 | () => HTMLElement | |
| autoSize | 自适应内容高度,可设置为 `true|false` 或对象:`{ minRows: 2, maxRows: 6 }`。 | boolean\|object | false |
| onResize | resize 回调 | function({ width, height }) | |

### Mentions 方法

Expand Down
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -123,7 +123,7 @@
"rc-dropdown": "~3.1.2",
"rc-field-form": "~1.4.1",
"rc-input-number": "~5.0.0",
"rc-mentions": "~1.2.0",
"rc-mentions": "~1.3.0",
"rc-menu": "~8.3.0",
"rc-notification": "~4.4.0",
"rc-pagination": "~2.2.5",
Expand Down