refactor(color-picker): ensure mode switches based on color value#3572
Merged
refactor(color-picker): ensure mode switches based on color value#3572
Conversation
16 tasks
commit: |
Contributor
8487ed1 to
c4d679e
Compare
50a1c78 to
52ae2e0
Compare
21efc6b to
64ed394
Compare
64ed394 to
992bee1
Compare
There was a problem hiding this comment.
Pull Request Overview
This PR refactors the color-picker component to ensure that it switches modes automatically based on the current color value while also addressing value formatting and event handling refinements.
- In trigger.tsx, the onBlur event has been replaced with onChange and the handleChange logic has been simplified.
- In panel/index.tsx, a new getModeByColor function is introduced to determine the mode from the input color, with corresponding updates to watch, mode change, and color-setting functions.
Reviewed Changes
Copilot reviewed 3 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/color-picker/trigger.tsx | Simplifies handleChange and changes the event trigger from onBlur to onChange. |
| src/color-picker/panel/index.tsx | Implements automatic mode switching using getModeByColor and refines color formatting. |
Files not reviewed (1)
- test/snap/snapshots/ssr.test.js.snap: Language not supported
19fdacc to
b7ba5f8
Compare
b7ba5f8 to
d782ad3
Compare
Collaborator
|
/update-common |
7d1e809 to
e230e0b
Compare
e230e0b to
41a3e66
Compare
f8cc7d2 to
e47a1e1
Compare
f63a03b to
8290490
Compare
0fc7388 to
d681c2a
Compare
87ca5a6 to
598e354
Compare
uyarn
approved these changes
May 6, 2025
Merged
16 tasks
uyarn
pushed a commit
that referenced
this pull request
Jun 11, 2025
) * refactor(color-picker): ensure mode switches based on color value * fix(color-picker): ensure gradient and alpha values update correctly * chore: update snapshots * fix(color-picker): update alpha format handling * fix(color-picker): ensure `onChange` includes `color` and `trigger` * fix(color-picker): avoid color update failure in controlled mode * chore: update common * refactor(color-picker): replace logic with functions from common repo * fix(color-picker): incorrect format mapping * chore(color-picker): remove `onClear` * chore: update submodule * docs(color-picker): remove the undeveloped `clear` event * chore: update snapshots * refactor(color-picker): remove unnecessary logic * chore: update snapshot * refactor(color-picker): exclude non-gradient values in gradient-only mode * docs(color-picker): update types and remove undeveloped props * fix(radio-group): highlight failure --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
uyarn
added a commit
that referenced
this pull request
Jun 11, 2025
* chore: add CHANGELOG (#3569) * chore(submodule): update _common (#3571) * refactor(upload): missing custom fail text implemention (#3574) * chore: update snapshots (#3575) * chore: update snapshots * chore: update snapshot --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> * feat(Icon): upgrade tdesign-icons-vue to 0.3.5 (#3577) * feat(select): add option removal handling for multiple selection (#3582) (#3584) * feat(select): add option removal handling for multiple selection (#3582) * chore: naming * chore: naming --------- Co-authored-by: wū yāng <uyarnchen@gmail.com> * fix(Select): 修复valueType:object与keys同时设置时的绑定值错误 (#3583) * refactor(color-picker): ensure mode switches based on color value (#3572) * refactor(color-picker): ensure mode switches based on color value * fix(color-picker): ensure gradient and alpha values update correctly * chore: update snapshots * fix(color-picker): update alpha format handling * fix(color-picker): ensure `onChange` includes `color` and `trigger` * fix(color-picker): avoid color update failure in controlled mode * chore: update common * refactor(color-picker): replace logic with functions from common repo * fix(color-picker): incorrect format mapping * chore(color-picker): remove `onClear` * chore: update submodule * docs(color-picker): remove the undeveloped `clear` event * chore: update snapshots * refactor(color-picker): remove unnecessary logic * chore: update snapshot * refactor(color-picker): exclude non-gradient values in gradient-only mode * docs(color-picker): update types and remove undeveloped props * fix(radio-group): highlight failure --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> * fix(tag): allow title rendering without max-width restriction (#3592) * chore(submodule): update _common (#3593) * fix(docs): add English component import for Guide (#3595) * feat(tag-input): show move cursor when draggable (#3594) * feat(tag-input): show move cursor when draggable * chore: update snapshot --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> * docs: update Chinese title for Dark Mode (#3596) * feat(InputNumber): add `enableRound` support to `decimalPlaces` prop (#3601) * chore(ci): generation vue pkg templates (#3603) * chore(ci): generation vue pkg templates * fix: change package manager from pnpm to npm in template generation script * fix: update package manager to pnpm in workflow and template generation script * 更新 pkg-pr-new.yml * 更新 pkg-pr-new-generate-template.mjs * 更新 pkg-pr-new-generate-template.mjs * 更新 pkg-pr-new-generate-template.mjs * 更新 pkg-pr-new-generate-template.mjs * chore: update diff --------- Co-authored-by: liweijie0812 <674416404@qq.com> * chore: optimize CHANGELOG.md file size (#3606) * chore: optimize CHANGELOG.md file size * chore: update typos config * docs: A new contributor graph that evaluates community activities from all dimensions (#3605) * docs: A new contributor graph that evaluates community activities from all dimensions. * chore: update params * chore: update params * Update README-zh_CN.md * Update README.md * Update README-zh_CN.md --------- Co-authored-by: wū yāng <uyarnchen@gmail.com> Co-authored-by: liweijie0812 <674416404@qq.com> * fix(drawer): `cancel-btn` and `confirm-btn` type supports `null` (#3612) * chore: pin cssstyle 4.3.1 (#3618) * fix(Table): sync columnCheckboxKeys on close (#3616) * fix(demo-page): remove`undefined` demo path and sort demos (#3615) refactor(demo-page): 重构 demos 页面优化路由监听及渲染逻辑 * chore: fix win run build (#3617) * chore: fix win run build * chore: add @types/node --------- Co-authored-by: Uyarn <uyarnchen@gmail.com> * fix(date-picker): using `popupProps` to control `visible` results in not being able to select time (#3600) * feat(tree): expand-all reactive (#3619) * chore: release 1.12.0 (#3620) * chore: release 1.12.0 * chore: changelog's changes --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> * chore: release 1.12.0-naruto * chore: fix lint * chore: update snapshot --------- Co-authored-by: TDesign bot <93915689+tdesign-bot@users.noreply.github.com> Co-authored-by: ngyyuusora <jiliangsoft@live.com> Co-authored-by: liweijie0812 <674416404@qq.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: richardji202 <69453277+richardji202@users.noreply.github.com> Co-authored-by: MorningUei <747651423@qq.com> Co-authored-by: Rylan <rylanbot@qq.com> Co-authored-by: betavs <34408516+betavs@users.noreply.github.com> Co-authored-by: 阿菜 Cai <jimmyrss1102@gmail.com> Co-authored-by: Shinji-Li <1349021570@qq.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

🤔 这个 PR 的性质是?
🔗 相关 Issue
💡 需求背景和解决方案
Tip
以下出现的双栏截图和视频,左边均是有问题的版本,右边是预期合理的版本
1. PC 端统一修复➕重构
② 新增最近使用颜色仍为渐变色,未更新为单色
#3566
② ♻️ 最近使用颜色、预设颜色 【视频 1-2-2】
② ♻️ 优化格式化返回值,例如 RGB 转为 RGBA,HSL 转为 HSLA 等
② 移除 onBlur 事件,避免与 onChange 重复触发
③ onChange 回调传入
context: { color: ColorObject; trigger: 'input' },符合文档标注的 TS 类型,避免返回给用户一个 undefined 或合成事件📝 更新日志
refactor(ColorPicker): 自动根据「触发器 / 最近颜色 / 预设颜色」的色值进行切换单色和渐变模式;只开启渐变模式时,过滤「预设颜色 / 当前颜色」中的非渐变色值;新增 format⚠️
HEX8,移除HSB;使用渐变模式的业务请注意此变更fix(ColorPicker): 开启透明通道时的返回值格式化异常
本条 PR 不需要纳入 Changelog
☑️ 请求合并前的自查清单