Skip to content

feat: textarea问题修复#49

Merged
dntzhang merged 4 commits into
mainfrom
feature/textarea
Jun 22, 2024
Merged

feat: textarea问题修复#49
dntzhang merged 4 commits into
mainfrom
feature/textarea

Conversation

@haishancai
Copy link
Copy Markdown
Collaborator

🤔 这个 PR 的性质是?

  • 日常 bug 修复

🔗 相关 Issue

💡 需求背景和解决方案

📝 更新日志

  • fix(组件名称): 处理问题或特性描述 ...

  • 本条 PR 不需要纳入 Changelog

☑️ 请求合并前的自查清单

⚠️ 请自检并全部勾选全部选项⚠️

  • 文档已补充
  • 代码演示已提供
  • TypeScript 定义已补充

@haishancai haishancai requested a review from duenyang June 21, 2024 07:04
@haishancai haishancai self-assigned this Jun 21, 2024
Comment thread src/textarea/README.md
{{ base }}

### 自定义事件

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

测试

Comment thread src/textarea/_example/status.tsx Outdated
Comment thread src/textarea/textarea.tsx Outdated
Comment on lines +77 to +94
if (autosize === true) {
node.addEventListener('input', () => {
const heightObj = calcTextareaHeight(node);
const clacMinHeight = heightObj.minHeight;
const clacHeight = heightObj.height;
node.style.minHeight = clacMinHeight;
node.style.height = clacHeight;
});
} else if (typeof autosize === 'object') {
node.addEventListener('input', () => {
const heightObj = calcTextareaHeight(node, autosize?.minRows, autosize?.maxRows);
const clacMinHeight = heightObj.minHeight;
const clacHeight = heightObj.height;
node.style.minHeight = clacMinHeight;
node.style.height = clacHeight;
});
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

代码重复度过高可以合并,另外不建议使用addEventListener可以在标签处使用 onInput={this.onInput},然后定义对应方法

@bind
onInput(){...}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done @duenyang

Comment thread src/textarea/textarea.tsx Outdated
});
}

inputValueChangeHandle = (e: Event) => {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

使用 omi的 @bind,调用处不需要使用箭头函数

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done @duenyang

@dntzhang dntzhang merged commit c03cc2c into main Jun 22, 2024
This was referenced Oct 17, 2024
This was referenced Dec 16, 2024
@liweijie0812 liweijie0812 deleted the feature/textarea branch May 9, 2026 07:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants