Skip to content

Commit

Permalink
feat(textarea): change event supports cursor parameter return (#2533)
Browse files Browse the repository at this point in the history
* feat(textarea): change event supports cursor parameter return

* docs(textarea): change and blur event supports cursor parameter return

* test(textarea): change event supports cursor parameter return
  • Loading branch information
betavs authored Jan 8, 2024
1 parent 9194981 commit da48df5
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/textarea/README.en-US.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ default-value | String | '' | uncontrolled property | N

name | params | description
-- | -- | --
blur | `(value: TextareaValue)` | \-
change | `(value: TextareaValue)` | \-
blur | `(value: TextareaValue, cursor: number)` | \-
change | `(value: TextareaValue, cursor: number)` | \-
enter | `(value: TextareaValue)` | \-
focus | `(value: TextareaValue)` | \-
line-change | `(value: TextareaValue)` | \-
Expand Down
4 changes: 2 additions & 2 deletions src/textarea/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@ hold-keyboard | Boolean | false | focus时,点击页面的时候不收起键

名称 | 参数 | 描述
-- | -- | --
blur | `(value: TextareaValue)` | 失去焦点时触发
change | `(value: TextareaValue)` | 输入内容变化时触发
blur | `(value: TextareaValue, cursor: number)` | 失去焦点时触发
change | `(value: TextareaValue, cursor: number)` | 输入内容变化时触发
enter | `(value: TextareaValue)` | 点击完成时触发
focus | `(value: TextareaValue)` | 获得焦点时触发
line-change | `(value: TextareaValue)` | 行高发生变化时触发
Expand Down
1 change: 1 addition & 0 deletions src/textarea/__test__/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ describe('textarea', () => {
expect(component.instance.data.count).toBe(10);
expect(handleChange.mock.calls[1][0].detail).toStrictEqual({
value: 'textarea用',
cursor: undefined,
});

$textarea.dispatchEvent('textarea', { detail: { value: 'textarea用于567' } });
Expand Down
4 changes: 2 additions & 2 deletions src/textarea/textarea.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,9 @@ export default class Textarea extends SuperComponent {
},

onInput(event) {
const { value } = event.detail;
const { value, cursor } = event.detail;
this.updateValue(value);
this.triggerEvent('change', { value: this.data.value });
this.triggerEvent('change', { value: this.data.value, cursor });
},
onFocus(event) {
this.triggerEvent('focus', {
Expand Down

0 comments on commit da48df5

Please sign in to comment.