-
Notifications
You must be signed in to change notification settings - Fork 211
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Add more menu selection customizability #1189
Comments
@Westbrook regarding our discussion about the |
Your approach to This version implies that
In this world would we also be able to leverage selects on
In that case would three elements have the Is there a specific use case that would become unavailable if only |
Ahhh -- I hadn't quite rationalized that. I do find it awkward that this is possible to write though:
How crazy is it to have the parent control create the |
For the parent to create the |
I'll carve out some time on Friday to do a spike here. While the sp-menu / re-parenting change doesn't seem necessary to address this issue, I'd also rather avoid too much unnecessary API churn if we can help it, and at least from a "clean API" standpoint (ignoring complexity), removing the need for Which is to say "I'll probably talk myself out of this". |
I'd do more on the manageSelection changes here, but I think we can remove a lot of this by using new options from #1189
I'd do more on the manageSelection changes here, but I think we can remove a lot of this by using new options from #1189
I'd do more on the manageSelection changes here, but I think we can remove a lot of this by using new options from #1189
I'd do more on the manageSelection changes here, but I think we can remove a lot of this by using new options from #1189
I'd do more on the manageSelection changes here, but I think we can remove a lot of this by using new options from #1189
I updated the examples above to remove |
We're getting close to a stable version of this, the main difference I'm running into is I don't think we can "inherit" by default and we need to make that explicit. See: https://westbrook-menu-selects--spectrum-web-components.netlify.app/storybook/?path=/story/menu-group--inherit In this way the contrived example above would require the following:
This is to easily clarify the state for the element to understand what it is doing and to ensure that the styling required for Menu Items that can be selected is applied without needing to autonomously sprout attributes. This also ensure that the API for groups is roughly the same as the API for root menus which should make them easier to understand to a developer leveraging the API. In the case of the original contrived code, without the |
I had a lot of trouble figuring out the right default here as well, and you know more about the different concerns here. This sounds good to me! |
This is a proposal to better support multiselect and un-selectable menu elements, and allow structured sub-handling in menu groups when necessary. It's modeled after the selects attribute already in sp-action-group. Creating this after a discussion with @Westbrook, and this is intended to consolidated/close issues #350 & #715
sp-action-menu supports new selects attribute
multiselect
With selects="multiple" any number of the items in the menu can be selected, and activating a menu item will toggle it's selected state.
single
With selects="single" zero or 1 item can be selected.
no selection (BREAKING CHANGE)
When the
selects
attribute is ommitted in sp-action-menu, items are not selectable. This better matches the general intent of action menu, where most items are actions that shouldn't be selected (e.g.File -> save...
isn't an item you'd expect to be selected)sp-picker & sp-split-button are single-select
There is no
selects
attribute for these controls, as they're designed to have a single value selected.sp-menu-group selects attribute
To allow for more granular selection handling,
sp-menu-group
also can provide aselects
attribute, in which case it takes over managing selection for that sub menu. When present, the parent control is not notified of selection changes.Example 1
This example shows an action menu that has both a multi-select and single-select group, along with an unselectable group. The
sp-menu-group
elements with theselects
attribute present should fire a change event when their selection state changes, while the action menu would not as the handling is managed by the menu group.Example 2 (contrived case)
While this example is contrived, it helps illustrate the ownership & management. Since the overall action menu has
selects="single"
, the unmanaged menu group for items 4 & 5 should be affected by that single select. Items 1-3 are managed by the multi-select menu group though. Clients should manage cases like this at the menu group level though.The text was updated successfully, but these errors were encountered: