diff --git a/src/textarea/README.en-US.md b/src/textarea/README.en-US.md index 3b746f05c..216e98db4 100644 --- a/src/textarea/README.en-US.md +++ b/src/textarea/README.en-US.md @@ -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)` | \- diff --git a/src/textarea/README.md b/src/textarea/README.md index a5073df7b..673801b84 100644 --- a/src/textarea/README.md +++ b/src/textarea/README.md @@ -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)` | 行高发生变化时触发 diff --git a/src/textarea/__test__/index.test.js b/src/textarea/__test__/index.test.js index 4ba58f6b0..56daa3415 100644 --- a/src/textarea/__test__/index.test.js +++ b/src/textarea/__test__/index.test.js @@ -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' } }); diff --git a/src/textarea/textarea.ts b/src/textarea/textarea.ts index a13fbeb36..5850e3cbe 100644 --- a/src/textarea/textarea.ts +++ b/src/textarea/textarea.ts @@ -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', {