-
-
Notifications
You must be signed in to change notification settings - Fork 50.1k
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(ColorPicker): add onClear #42634
feat(ColorPicker): add onClear #42634
Conversation
补个 |
单测挂了,本地调试一下。 |
@RedJue 这个单测不知道怎么不行,你看看 |
还有个问题,一直点击清除,会一直触发 onChange 和 onClear,0 和 100 会反复切换,这是故意为之还是 bug?已经是 clear 状态再点清除不是应该什么都不发生吗 |
是 |
这个可以跟 清空后不隐藏面板 的问题一起修复,然后提 pr 到 master |
fireEvent.click(container.querySelector('.ant-color-picker-trigger')!); | ||
await waitFakeTimer(); | ||
expect(container.querySelector('.ant-popover-hidden')).toBeFalsy(); |
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.
这里不需要去掉,点击之后 弹窗应该弹出来。
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.
加上了之后,最后那行还是 0%,得不到 100%
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.
这个和单测结果错误不相关。
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.
我知道不一样,删掉那几行是可以了,但是这几行看上去感觉没问题。
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.
有问题,现在是点击清空不关闭弹窗,删掉那部分逻辑是按之前点击清空关闭弹窗来走的,按现在逻辑再点击就关闭了,自然触发就有问题。
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.
这几行意思是点击一下方块,获取值是 0,应该没问题吧,跟是否关闭弹窗有关系么。删了删了,等另一个 pr 合并再更新这里的。
猜测可能单测里行为和现在的预期不一样,尝试删掉这几行 https://github.com/ant-design/ant-design/pull/42634/files#diff-aa06460351e8630f305cf6509e8137984e0f167ab2560da22874033189234fb4L99-L103 试试 |
5bb31ad
to
a6617c9
Compare
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## feature #42634 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 641 641
Lines 10891 10889 -2
Branches 2958 2957 -1
=========================================
- Hits 10891 10889 -2
☔ View full report in Codecov by Sentry. |
@@ -1,7 +1,7 @@ | |||
## zh-CN | |||
|
|||
清除已选择的颜色。 | |||
清除已选择的颜色。可以使用受控 open 和 onClear 控制清除时关闭弹窗。 |
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.
demo 分两个吧,一个最基础的用法,一个配合 onClear
实现弹窗关闭。
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.
其实我觉得就只要最基础的用法就好了,配合 onClear 关闭没有必要。
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.
不加应该问题也不大,先这样吧。
[中文版模板 / Chinese template]
🤔 This is a ...
🔗 Related issue link
#42406
💡 Background and solution
应该让用户自己控制清除时是否关闭,用 open 受控配合 onClear 实现,或者加一个类似 closePopupWhenClear 属性。
📝 Changelog
☑️ Self-Check before Merge
🚀 Summary
🤖 Generated by Copilot at e45c232
Added a new
onClear
prop to theColorPicker
component to customize the behavior when clearing the color. Refactored the color picker panel props and the popup closing and color clearing logic. Updated the documentation and the test case accordingly.🔍 Walkthrough
🤖 Generated by Copilot at e45c232
onClear
prop toColorPickerProps
interface andColorPicker
component to allow custom callback function when clearing the color (link, link, link, link, link, link, link)handleClear
function inColorPicker
component to setcolorCleared
state and callonClear
prop function without passing boolean parameter (link)useEffect
hook and import fromColorPicker
component as popup closing logic is moved tohandleClear
function (link, link)onClear
prop inColorPickerPanelProps
interface andColorPickerPanel
component to a function without parameters to matchColorPickerProps
andhandleClear
function (link, link)onFormatChange
prop fromColorPickerProps
toColorPickerPanelProps
as it is more relevant for customizing color format (link, link, link, link)onChange
andonOpenChange
props fromColorPickerProps
toColorPickerPanelProps
as they are more relevant for customizing color picker panel behavior (link, link)components/color-picker/__tests__/index.test.tsx
as it is handled byhandleClear
function (link)