Skip to content
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

prefer: optimize allow clear logic #42439

Merged
merged 4 commits into from
May 19, 2023

Conversation

RedJue
Copy link
Member

@RedJue RedJue commented May 17, 2023

[中文版模板 / Chinese template]

🤔 This is a ...

  • New feature
  • Bug fix
  • Site / documentation update
  • Demo update
  • Component style update
  • TypeScript definition update
  • Bundle size optimization
  • Performance optimization
  • Enhancement feature
  • Internationalization
  • Refactoring
  • Code style optimization
  • Test Case
  • Branch merge
  • Workflow
  • Other (about what?)

🔗 Related issue link

💡 Background and solution

📝 Changelog

Language Changelog
🇺🇸 English Optimize the allowClear interaction logic, reopening the panel to select a color will default to 100% transparency instead of 0%.
🇨🇳 Chinese 优化 allowClear交互逻辑,重新打开面板选择颜色会默认 100% 透明度,而不是 0%。

☑️ Self-Check before Merge

⚠️ Please check all items below before requesting a reviewing. ⚠️

  • Doc is updated/provided or not needed
  • Demo is updated/provided or not needed
  • TypeScript definition is updated/provided or not needed
  • Changelog is provided or not needed

🚀 Summary

🤖 Generated by Copilot at aefdeda

This pull request improves the color-picker component by adding more tests and fixing a bug with the alpha slider. The tests cover the basic interactions with the component, and the bug fix ensures that the alpha slider resets correctly after clearing the color.

🔍 Walkthrough

🤖 Generated by Copilot at aefdeda

  • Fix a bug where the alpha slider of the color picker would not reset to 100% after clearing the color by adding a condition to check the alpha value and generate a new color object (link) in components/color-picker/ColorPicker.tsx
    • The color picker can be opened and closed by clicking the trigger button (link)
    • The color picker can be cleared by clicking the clear button and the color value is set to an empty string (link)
    • The color picker can accept a hex input and the alpha slider is set to 100% after clearing and re-entering a color (link)

@github-actions
Copy link
Contributor

github-actions bot commented May 17, 2023

@MadCcc
Copy link
Member

MadCcc commented May 17, 2023

changelog 可以写详细一些

@RedJue
Copy link
Member Author

RedJue commented May 17, 2023

changelog 可以写详细一些

ok

@codecov
Copy link

codecov bot commented May 17, 2023

Codecov Report

Patch coverage: 100.00% and no project coverage change.

Comparison is base (c61ea98) 100.00% compared to head (7b6f664) 100.00%.

Additional details and impacted files
@@            Coverage Diff            @@
##            master    #42439   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          640       640           
  Lines        10819     10823    +4     
  Branches      2936      2937    +1     
=========================================
+ Hits         10819     10823    +4     
Impacted Files Coverage Δ
components/color-picker/ColorPickerPanel.tsx 100.00% <ø> (ø)
components/color-picker/ColorPicker.tsx 100.00% <100.00%> (ø)

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@kiner-tang
Copy link
Member

覆盖率掉了

@RedJue
Copy link
Member Author

RedJue commented May 17, 2023

覆盖率掉了

看到了,在修复

@li-jia-nan
Copy link
Member

li-jia-nan commented May 18, 2023

好像还是 0%:

Kapture.2023-05-18.at.14.34.54.mp4

@RedJue
Copy link
Member Author

RedJue commented May 18, 2023

需要操作一下才行,随便拖动一下色板

@li-jia-nan
Copy link
Member

感觉这样有点奇怪,不拖动色板可以实现吗?

@RedJue
Copy link
Member Author

RedJue commented May 18, 2023

感觉这样有点奇怪,不拖动色板可以实现吗?

没操作那肯定还是清空的状态,你只是打开面板而已,不应该去动清空的状态,这个符合常识,不然我每次打开清空就没了,感觉像个bug

@li-jia-nan
Copy link
Member

感觉这样有点奇怪,不拖动色板可以实现吗?

没操作那肯定还是清空的状态,你只是打开面板而已,不应该去动清空的状态,这个符合常识,不然我每次打开清空就没了,感觉像个bug

OK,那让 @MadCcc 闲夕大佬看一下吧,没问题就合了

@MadCcc
Copy link
Member

MadCcc commented May 18, 2023

后续可以细化一下 onChange 的行为,比如可以把 target 传进来,如果是 alpha type 直接过滤掉就行。

这个不如直接在这个 PR 做掉吧

@RedJue
Copy link
Member Author

RedJue commented May 18, 2023

后续可以细化一下 onChange 的行为,比如可以把 target 传进来,如果是 alpha type 直接过滤掉就行。

这个不如直接在这个 PR 做掉吧

可以,我在 rc 加个属性好了

@@ -9,7 +10,7 @@ import ColorPresets from './components/ColorPresets';
import type { ColorPickerBaseProps } from './interface';

interface ColorPickerPanelProps extends ColorPickerBaseProps {
onChange?: (value?: Color) => void;
onChange?: (value?: Color, type?: HsbaColorType) => void;
Copy link
Member

Choose a reason for hiding this comment

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

type 先不要透出去

@MadCcc MadCcc merged commit d61c08e into ant-design:master May 19, 2023
52 checks passed
@MadCcc MadCcc mentioned this pull request May 22, 2023
20 tasks
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.

None yet

4 participants