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(textarea): change event supports cursor parameter return #2533

Merged
merged 3 commits into from
Jan 8, 2024
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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