feat(ButtonGroup): support button-group component#13774
feat(ButtonGroup): support button-group component#13774wjw-gavin wants to merge 3 commits intoyouzan:mainfrom
Conversation
Summary of ChangesHello @wjw-gavin, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request introduces a new Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request introduces a new ButtonGroup component, allowing multiple buttons to be grouped together and inherit common properties like type, size, and round. The changes include adding the ButtonGroup component, integrating it with the existing Button component for prop inheritance, updating documentation, and adding corresponding styles and tests. Overall, the implementation is well-structured and adds valuable functionality.
| props.size === 'normal' && group?.props.size | ||
| ? group.props.size | ||
| : props.size; | ||
| const round = props.round || group?.props.round; |
There was a problem hiding this comment.
The inheritance logic for the round prop has a potential bug. Since round is a Boolean prop, props.round will always be true or false. If a user explicitly sets :round="false" on a Button within a ButtonGroup that has round, the button will still inherit round from the group because false || group?.props.round would evaluate to group?.props.round (which is true). This prevents explicit false overrides.
To correctly handle explicit false values overriding parent props, you need to check if the prop was explicitly passed. A common pattern for this is to check vnode.props or adjust the prop definition to allow undefined as a default, then check for undefined.
For example, you could modify the buttonProps definition for round to allow undefined as a default, or use getCurrentInstance() to check instance.vnode.props.
| const round = props.round || group?.props.round; | |
| const round = props.round !== undefined && props.round !== null ? props.round : group?.props.round; |
There was a problem hiding this comment.
vue 的 Boolean prop 在未传时值是 false 不是 undefined 把,这样无法继承 group 属性了。
另外看 checker 中貌似是同样的问题,使用 getCurrentInstance 检查是否显式传入?
related: #13675
Before submitting a pull request, please read the contributing guide.
在提交 pull request 之前,请阅读 贡献指南。