Skip to content

Commit fc530a1

Browse files
authored
feat(Textarea): add allowInputOverMax prop to control input behavior after exceeding maxlength (#3691)
1 parent c57462a commit fc530a1

File tree

5 files changed

+12
-3
lines changed

5 files changed

+12
-3
lines changed

src/textarea/props.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ import { TdTextareaProps } from './type';
88
import { PropType } from 'vue';
99

1010
export default {
11+
/** 超出 `maxlength` 或 `maxcharacter` 之后是否还允许输入 */
12+
allowInputOverMax: Boolean,
1113
/** 自动聚焦,拉起键盘 */
1214
autofocus: Boolean,
1315
/** 高度自动撑开。 autosize = true 表示组件高度自动撑开,同时,依旧允许手动拖高度。如果设置了 autosize.maxRows 或者 autosize.minRows 则不允许手动调整高度 */

src/textarea/textarea.en-US.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
name | type | default | description | required
77
-- | -- | -- | -- | --
8-
allowInputOverMax | Boolean | false | \- | N
8+
allowInputOverMax | Boolean | false | Allow input after exceeding `maxlength` or `maxcharacter` | N
99
autofocus | Boolean | false | \- | N
1010
autosize | Boolean / Object | false | Typescript:`boolean \| { minRows?: number; maxRows?: number }` | N
1111
disabled | Boolean | false | \- | N

src/textarea/textarea.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
名称 | 类型 | 默认值 | 说明 | 必传
77
-- | -- | -- | -- | --
8-
allowInputOverMax | Boolean | false | 超出maxlength或maxcharacter之后是否还允许输入 | N
8+
allowInputOverMax | Boolean | false | 超出 `maxlength``maxcharacter` 之后是否还允许输入 | N
99
autofocus | Boolean | false | 自动聚焦,拉起键盘 | N
1010
autosize | Boolean / Object | false | 高度自动撑开。 autosize = true 表示组件高度自动撑开,同时,依旧允许手动拖高度。如果设置了 autosize.maxRows 或者 autosize.minRows 则不允许手动调整高度。TS 类型:`boolean \| { minRows?: number; maxRows?: number }` | N
1111
disabled | Boolean | false | 是否禁用文本框 | N

src/textarea/textarea.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,9 @@ export default mixins(Vue as VueConstructor<Textarea>, classPrefixMixins).extend
184184
}
185185
if (this.maxcharacter && this.maxcharacter >= 0) {
186186
const stringInfo = getCharacterLength(val, this.maxcharacter);
187-
val = typeof stringInfo === 'object' && stringInfo.characters;
187+
if (!this.allowInputOverMax) {
188+
val = typeof stringInfo === 'object' && stringInfo.characters;
189+
}
188190
}
189191
}
190192

src/textarea/type.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@
77
import { TNode } from '../common';
88

99
export interface TdTextareaProps {
10+
/**
11+
* 超出 `maxlength` 或 `maxcharacter` 之后是否还允许输入
12+
* @default false
13+
*/
14+
allowInputOverMax?: boolean;
1015
/**
1116
* 自动聚焦,拉起键盘
1217
* @default false

0 commit comments

Comments
 (0)