-
Notifications
You must be signed in to change notification settings - Fork 345
refactor(color-picker): ensure mode switches based on color value #3503
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
commit: |
58a1e71
to
755528d
Compare
67b2c23
to
562f3f6
Compare
303c1c5
to
907fca3
Compare
907fca3
to
cf117e8
Compare
850c07d
to
2e6c93f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR refactors several components of the ColorPicker and related components to ensure the color mode switches correctly based on the color value while cleaning up unused props and improving event handling. Key changes include:
- Removal of unused props and cleanup functions in the RadioGroup and ColorPicker interfaces.
- Refactoring of change handling in the trigger component to use direct prop values and improved callback parameters.
- Updates in the panel component to auto-detect color modes based on the input value, adjust format conversion for alpha channels, and streamline UI updates.
Reviewed Changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.
Show a summary per file
File | Description |
---|---|
packages/components/radio/RadioGroup.tsx | Removed redundant observer cleanup logic; ensure proper observer disconnection. |
packages/components/color-picker/interface.ts | Removed unused props for cleaner interface. |
packages/components/color-picker/components/trigger.tsx | Refactored controlled input handling and event callbacks. |
packages/components/color-picker/components/panel/index.tsx | Revised mode detection, format conversion logic, and event handlers. |
packages/components/color-picker/components/panel/header.tsx | Removed unused togglePopup prop from header. |
packages/components/color-picker/tests/color-picker.test.tsx | Updated tests to reflect changes in gradient and pure-color mode handling. |
Comments suppressed due to low confidence (1)
packages/components/radio/RadioGroup.tsx:87
- The removal of the clearObserver logic in the conditional branch may leave stale observers attached when barStyle.width is non-zero. Consider verifying that observer cleanup is handled appropriately in all cases.
if (barStyle && barStyle.width !== '0px') {
d5229a4
to
8179ec6
Compare
9c940f6
to
d5301ad
Compare
d5301ad
to
1ddc014
Compare
Note 需要等 common 仓库 PR Tencent/tdesign-common#2110 合并,针对 commit 1ddc014 变动的测试才能通过,且还需要同步对应的公共方法 |
This comment was marked as outdated.
This comment was marked as outdated.
1 similar comment
/update-common |
0963102
to
13fc894
Compare
🤔 这个 PR 的性质是?
🔗 相关 Issue
💡 需求背景和解决方案
Tip
以下出现的双栏截图和视频,左边均是有问题的版本,右边是预期合理的版本
1. PC 端统一修复➕重构
② 新增最近使用颜色仍为渐变色,未更新为单色
Tencent/tdesign-vue#3566
② ♻️ 最近使用颜色、预设颜色 【视频 1-2-2】
② ♻️ 优化格式化返回值,例如 RGB 转为 RGBA,HSL 转为 HSLA 等
② 移除 onBlur 事件,避免与 onChange 重复触发
③ onChange 回调传入
context: { color: ColorObject; trigger: 'input' }
,符合文档标注的 TS 类型,避免返回给用户一个 undefined 或合成事件2. React 特有 Bug 修复
- 在实现 1.2 的功能时, 发现 Radio 经常无法触发高亮
- common 的
obeserve()
内部已经主动unobserve
了,所以我觉得暂时不需要外部再进行disconnect
,性能目前看来影响不大,主动销毁反而造成一些极端情况下的计算失败5. 解决方案总结
细节比较多,不方便全部一一说明。部分问题均是 Color 实例内部的 isGradiant 没有同步导致的,可以参考这里的注释 Tencent/tdesign-common@1124592
📝 更新日志
refactor(ColorPicker): 自动根据「触发器 / 最近颜色 / 预设颜色」的色值进行切换单色和渐变模式;只开启渐变模式时,过滤「预设颜色 / 当前颜色」中的非渐变色值;新增 format⚠️
HEX8
,移除HSB
;使用渐变模式的业务请注意此变更feat(ColorPicker): 新增
enableMultipleGradient
API,默认开启fix(ColorPicker): 修复渐变点无法正常更新颜色和位置;开启透明通道时的返回值格式化异常
本条 PR 不需要纳入 Changelog
☑️ 请求合并前的自查清单