-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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: add experimental combo-button and menu-button components #13224
Conversation
✅ Deploy Preview for carbon-components-react ready!Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify site settings. |
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.
Very cool, this looks great to me! Keyboard navigation works as expected. I really like how it uses the existing MenuItem
components - another great example of how composable those components are. For some reason I assumed this would need to be implemented using Popover
, but using Menu
makes sense.
I'll defer to @laurenmrice on the decision of the secondary/tertiary/ghost variants, but to me the ghost one in particular seems problematic. It's visually very similar to the Inline Dropdown.
Since this is using the MenuItem
components, I assume the items inherently support being individually disabled?
@tay1orjones Yes, passing |
Just pushed an update adding a disabled |
@tay1orjones @francinelucca I just pushed another update adding another experimental component For now it's two separate components even though the logic is very similar, but I could see this being more flexible with the button kinds it would support, hence the separation. In this regard I outsourced the main logic to an internal hook Obviously nothing of this is set in stone and I'll keep this PR in draft status until we discussed further. I just wanna provide proof of concepts as it's easier to talk about working code than thoughts. 😉 I'll also connect with @Laura-Marshall as I know she worked quite a bit on buttons recently and wanna make sure she's in the loop. |
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.
mostly LGTM, just one minor comment about accepting a className
Behavior-wise I was kind of expecting the ComboButton/MenuButton's focus to move onto the first Any thoughts here @mbgower ? https://deploy-preview-13224--carbon-components-react.netlify.app/?path=/story/experimental-unstable-combobutton--playground |
I think one of two things needs to happen when the menu is opened: either the focus needs to stay on the open/close button, or it needs to go to the first item. As it is, it goes 'nowhere'. I agree that putting the focus on the first item when the menu is opened is the best. That is a standard thing to do with a menu. It makes sense from an interaction perspective here; forcing the user to press down after opening just to get focus there seems pointless. (BTW, pressing Enter also puts focus on the first item, I discovered.) |
@mbgower when the menu opens, the focus is currently set on the entire menu widget. Any key event that is not escape will move the focus on the first item with the only exception of Arrow up which will focus the last item instead of the first. I thought this is how the menu widget was specified at one point but either I'm remembering wrongly or it was updated (maybe you would know?). In any case: that can easily be adjusted. While reading through the current APG design pattern it also mentioned the focus should cycle through (after last item, the first item should be focused again and vice versa). This was also reported a while back in #8076 If you agree I'll update the behaviour of the @francinelucca Thanks for catching that! I've added it to the list of remaining work items in the first comment. Does this mean the general structure and idea is fine with you two (cc @tay1orjones) and I should go ahead an add these items to the PR? |
Created issue for Menu focus: #13265 |
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.
Almost there! Super minor details
@janhassel This looks great Jan, thanks for working on this. ⭐️ Below are some comments I have and addressing some of your questions: Supporting different button types for combo button
Visual differences
React preview link for Combo button
|
@laurenmrice Thanks for the review! I just pushed an update that should fix the issues you were experiencing in Firefox. The subtle border on disabled buttons seems to be an issue with the button component itself so I'd say this should be a separate issue. You can re-produce this in the storybook: https://react.carbondesignsystem.com/?path=/story/components-button--default&args=disabled:true&globals=theme:g100 irt the dividers: personally, I'm not a fan of creating and maintaining two different styles for the same component depending on their context in this way. Zooming out, the Menu component (with it's sub components – MenuItem, ...) could be used anywhere in Carbon where a menu design pattern is applied: context menus, overflow menus, combo buttons, menu buttons (and potentially header menu in the future?). We can leverage the same components and therefore the same styles everywhere to create a true "Menu" feel for Carbon. Also I don't think it's too bad to differentiate it from the dropdown slightly as dropdowns shouldn't be misused as menus. Maybe as it's not too clear from the storybook demo, the dividers can be freely placed by the consumer, like so:
Keeping the same components and styles will allow us to save resources in both dev and figma maintenance (the children of each of the top-level components would all just be MenuItem and its variants). Let me know if you disagree! |
Okay, good to know! We can fix that on our end, and I can open an issue for it. 👍 Dividers discussion |
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.
Looks good to me, Jan. Thank you for contributing this! ✨✅
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.
@janhassel can we address this one #13224 (comment) 🙏🏻. Should be good to go after
@francinelucca Oh sorry, I must've missed your response in that thread. Just updated to remove them entirely from the controls table 🙂 |
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.
@francinelucca Sorry, I misunderstood what you meant in the first place. Let me know if it's all fixed now! |
Closes #3371
After working on #13146 I couldn't help myself but wondering how much work it would actually be to utilize the
Menu
component for the long-standing and accepted proposal of aComboButton
as theMenu
should provide all the flexibility to leverage it in many different contexts (related: #1903).Opening as draft as I have some questions regarding the button kinds that should be supported:
IconButton
supports for this proof of concept and think the secondary works well. Both ghost and tertiary though don't work all that good from a visual perspective:-1px
to overlay the right outline of the primary action and the left outline of the trigger. Not sure if it's intended from design though.Changelog
New
ComboButton
based onMenu
Testing / Reviewing
Storybook for now mainly. If the core Carbon team is happy with this approach, I will add the remaining topics:
props.className
@laurenmrice there are some slight visual differences between your last shared design spec and the implementation as it uses the design spec of the
Menu
component which, for example, doesn't have the indented dividing lines in between each option. I think it's best to keep these styles consistent so that aMenuItem
looks and feels the same everywhere it is used, but do let me know if you disagree!