fix(button): taro button cannot be compiled into an h5 tag#2998
fix(button): taro button cannot be compiled into an h5 tag#2998oasis-cloud wants to merge 1 commit intojdf2e:feat_v3.xfrom
Conversation
Walkthrough该 PR 修改了 button 组件的实现,将原先依赖 TaroButton 的方式替换为使用原生 HTML 的 Changes
Possibly related PRs
Poem
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## feat_v3.x #2998 +/- ##
==========================================
Coverage 85.79% 85.79%
==========================================
Files 281 281
Lines 18527 18527
Branches 2810 2810
==========================================
Hits 15896 15896
Misses 2626 2626
Partials 5 5 ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
src/packages/button/button.taro.tsx (1)
149-174: 建议优化按钮实现的类型安全性当前实现存在以下几点可以改进的地方:
- 使用
form-type属性需要禁用 ESLint 规则,这不是最佳实践- 类型定义可以更严格
建议如下修改:
- <button + <button + type={nativeType} {...rest} ref={ref} - /* eslint-disable-next-line react/no-unknown-property */ - form-type={nativeType} - type={nativeType} + data-form-type={nativeType} className={buttonClassNames} style={{ ...getStyle, ...style }} onClick={(e) => handleClick(e as any)} >这样可以:
- 避免使用 ESLint 禁用注释
- 使用
data-属性来保持与原有功能的兼容性- 确保
type属性位于其他属性之前,防止被rest覆盖
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
src/packages/button/button.taro.tsx(3 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: test
🔇 Additional comments (2)
src/packages/button/button.taro.tsx (2)
2-2: 导入更改看起来合理!移除
TaroButton的导入并保留类型定义是正确的做法,这与使用原生 HTML button 元素的目标相符。Also applies to: 4-4
143-145:Details
❓ Verification inconclusive
验证 WEB 环境下的类型处理
当前在 WEB 环境下的类型转换逻辑可能需要更新以匹配新的实现方式。
🏁 Script executed:
#!/bin/bash # 检查是否存在其他使用 formType 的地方 rg "formType" --type ts --type tsxLength of output: 62
请核查 WEB 环境下的类型转换逻辑一致性
目前代码在 WEB 环境中将
rest.formType赋值给rest.type。由于我们在自动搜索formType的过程中遇到了文件类型识别的问题(例如tsx未被正确识别),请你手动验证整个代码库中是否存在其他相关用法,确保所有组件中的类型处理逻辑均已与最新实现保持一致。如果有其他地方也依赖于formType的转换,请同步相应更新。
- 请检查
src/packages/button/button.taro.tsx文件中(第 143-145 行)的处理是否符合预期。- 手动搜索或验证其他
.ts和.tsx文件中对formType的使用情况,以避免遗漏修改。
xiaoyatong
left a comment
There was a problem hiding this comment.
这个是不是可以区分一下 web 和 其他端。
Summary by CodeRabbit