feat(action-menu): S2 migration [CSS-1160]#4085
Conversation
📚 Branch previewPR #4085 has been deployed to Azure Blob Storage: https://spectrumcss.z13.web.core.windows.net/pr-4085/index.html. |
File metricsSummaryTotal size: 1.43 MB* Table reports on changes to a package's main file. Other changes can be found in the collapsed Details section below.
File change detailsactionbutton
actiongroup
actionmenu
menu
popover
* An ASCII character in UTF-8 is 8 bits or 1 byte. |
2729f84 to
779e411
Compare
🦋 Changeset detectedLatest commit: 1f94719 The changes in this PR will be included in the next version bump. This PR includes changesets to release 6 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
635f709 to
242929c
Compare
4baa099 to
eb8cde2
Compare
313ee43 to
3babcfa
Compare
4d618da to
f3fa4d4
Compare
f2ef53c to
409436c
Compare
dbd613f to
00038a9
Compare
9ac107e to
40b49ff
Compare
| labelledby: { table: { disable: true } }, | ||
| items: { table: { disable: true } }, | ||
| role: { table: { disable: true } }, | ||
| subrole: { table: { disable: true } }, |
There was a problem hiding this comment.
Subrole ended up being easier to intuit from the role instead of passing it through from the parent.
| )} | ||
| </ul> | ||
| `, | ||
| Template: ({ |
There was a problem hiding this comment.
Letting the template handle this logic because it's a bit duplicative to redefine it here and could lead to mismatches.
| testHeading: "No selection, with thumbnails", | ||
| description: undefined, | ||
| thumbnailUrl: "thumbnail.png" | ||
| hasThumbnail: true, |
There was a problem hiding this comment.
Since thumbnail.png is the default, just the hasThumbnail is sufficient.
| isCollapsible = false, | ||
| label, | ||
| rootClass, | ||
| role, |
There was a problem hiding this comment.
Labels can have roles too! 🥳
| return html` | ||
| <span | ||
| role=${ifDefined(role)} | ||
| id=${ifDefined(id)} |
There was a problem hiding this comment.
Need the id and role for switch labels.
| "a.spectrum-ActionButton" | ||
| ], | ||
| "modifiers": [ | ||
| "--mod-actionbutton-animation-duration", |
There was a problem hiding this comment.
Since this is for S2 and we've agreed to remove modifiers, I removed the mods on any lines I needed to update for this change anyway.
| } | ||
|
|
||
| /* Focus indicator */ | ||
| .spectrum-ActionButton { |
There was a problem hiding this comment.
Just me tidying up a bit by combining these styles in with the initial definition for .spectrum-ActionButton
| * By default, the menu is opened by pressing the trigger element or activating it via the <kbd>Space</kbd> or <kbd>Enter</kbd> keys. However, there may be cases where the trigger should perform a separate action on press such as selection, and should only display the menu when long pressed. For this use-case, the menu will only be opened when pressing and holding the trigger or by using the <kbd>Option</kbd> (Alt on Windows) + <kbd>Down arrow</kbd>/<kbd>Up arrow</kbd> keys while focusing the trigger. | ||
| * | ||
| * This example illustrates the expected visuals and states of the action menu for a trigger with both long press and short press behaviors. | ||
| */ |
There was a problem hiding this comment.
😍 love this description!
I don't see the long press working here (I can't access the menu for long press), but I don't think we expect it to, is that correct?
There was a problem hiding this comment.
Yeah I took a first pass at making the long-press functional and then thought, this feels a little out-of-scope. Do you think it's worth making it work or should I just note that it doesn't work in CSS but does in SWC?
There was a problem hiding this comment.
@castastrophe I like your note that the longpress isn't functional in our docs. We could even link to an example or any longPress documentation we have in SWC.
There was a problem hiding this comment.
I noticed what I thought was maybe a regression for the Media Options story on the Coachmark docs page:

The container has a height being set on it in the customStyles, wondering if removing that would help?
I couldn't figure out what would have introduced it here though, and I assumed it was a regression from something in this branch because I don't see it in the spectrum-two branch preview.
But I do see the same issue when I run spectrum-two locally so I'm wondering if it's something from #4174 maybe, since it looks like that's where the need for some of those explicit dimensions on popover was eliminated?
There was a problem hiding this comment.
As a side note, I also have been noticing some weirdness here, but it's inconsistent so I'm not sure what we should do about it. Sometimes when I open the coachmark component story (on local or preview) the height or sometimes width of the component increases infinitely. It doesn't happen every time, but I'm thinking it's triggered if I open the Coachmark Default story after the Action menu story (I was able to replicate in Firefox, Chrome, and Safari).
It also happens in popover, also if I click into the Popover story after Action menu:
There was a problem hiding this comment.
Okay, Steph saw some of that too until she'd done a hard refresh. I wonder if it's an inconsistent bug.
There was a problem hiding this comment.
Try this and see if you can replicate it, this is what I'm finding that breaks it (regardless of browser):
- Open the Action menu component in Storybook (Docs page or Default story, it doesn't matter, as long as the popover is open, this won't happen if the action menu popover stays closed)
- Open either the Coach mark component or the Popover component in Storybook (Docs page or Default story)
- Expect to see either the height or width of the popover there expand infinitely until you refresh
I think there's something about Action menu, because I can go between Coach mark and Popover just fine.
Another thing I noticed is that if I start on the Popover with position bottom, then go to Action menu where bottom isn't a valid option (there's only bottom-start and bottom-end), then go back to Popover, the popover ends up in a completely different position. Unsure if that's related or not, but something I noticed.

Unless you've got an idea on how to address it, I'm cool with a follow-up ticket.
There was a problem hiding this comment.
I think I've finally got this resolved, would you mind validating on your system as well to be sure? Thank you!
There was a problem hiding this comment.
I am still seeing the issue when navigating from an open action menu to something like popover or coachmark without refreshing, both locally and in the PR preview 😕
There was a problem hiding this comment.
In the end, I've opted to demo the coach mark with just the action button but not the full action menu. I think the issues around rendering the menu as interactive aren't necessarily worth fixing in CSS at this time just for the purposes of the demo (plus I recall we were deprecating the use of action menu inside the coach mark header).
There was a problem hiding this comment.
I'm seeing this as well — do we need to increase the height for that Coachmark example? ✨
rise-erpelding
left a comment
There was a problem hiding this comment.
I left more details on some of the popover issues I've been noticing, I'd love to hear your thoughts! I'm cool with these being a follow-up ticket if they can't be solved here.
Otherwise, just some minor adjustments needed, I think!
There was a problem hiding this comment.
Try this and see if you can replicate it, this is what I'm finding that breaks it (regardless of browser):
- Open the Action menu component in Storybook (Docs page or Default story, it doesn't matter, as long as the popover is open, this won't happen if the action menu popover stays closed)
- Open either the Coach mark component or the Popover component in Storybook (Docs page or Default story)
- Expect to see either the height or width of the popover there expand infinitely until you refresh
I think there's something about Action menu, because I can go between Coach mark and Popover just fine.
Another thing I noticed is that if I start on the Popover with position bottom, then go to Action menu where bottom isn't a valid option (there's only bottom-start and bottom-end), then go back to Popover, the popover ends up in a completely different position. Unsure if that's related or not, but something I noticed.

Unless you've got an idea on how to address it, I'm cool with a follow-up ticket.
rise-erpelding
left a comment
There was a problem hiding this comment.
I’m still seeing some issues with Action Menu/Popover. I’ve documented most inline and tested across multiple browsers, so hopefully they’re reproducible on your end.
The CSS looks solid overall, though! I wonder if simplifying some of the JS implementation could help stabilize things so we can ship this.
There was a problem hiding this comment.
I am still seeing the issue when navigating from an open action menu to something like popover or coachmark without refreshing, both locally and in the PR preview 😕
rise-erpelding
left a comment
There was a problem hiding this comment.
I looked at this quickly and noted that the popover issues from before are resolved! 🎉 Really, really nice work!
I did check out Coachmark after I checked out Action menu and Popover, and I'm seeing a similar issue there, but only after switching on "has action menu":

It's also visible from the docs page.
cdransf
left a comment
There was a problem hiding this comment.
This looks awesome! Just have a few minor questions. ✨
There was a problem hiding this comment.
I'm seeing this as well — do we need to increase the height for that Coachmark example? ✨
marissahuysentruyt
left a comment
There was a problem hiding this comment.
I wanted to leave the comments I had so far! I need to go through the menu and popover changes a little more thoroughly tomorrow!
| }, | ||
| menuArgs: { | ||
| customStyles: { | ||
| "--mod-menu-inline-size": "max-content", |
There was a problem hiding this comment.
You may have already left a comment somewhere about this, but instead of using the mod here, is it possible to use a --spectrum custom property? If we're going to remove mods, would it make sense to not introduce another place where one is being used?
There's a couple more menu mods in the PlaceholderIcons args as well.
There was a problem hiding this comment.
I think removing the mods in some of these more complex components are going to be a bigger project and I didn't want to expand the scope of action menu by addressing that quite yet.
marissahuysentruyt
left a comment
There was a problem hiding this comment.
I was too slow reviewing, but didn't want my comments to be lost!
| ${Template({ | ||
| ...args, | ||
| hasPopup: "true", | ||
| hasLongPress: true, |
There was a problem hiding this comment.
Do we need an isOpen arg in any of the tests? Not sure if it's valuable, especially if other args are already covering the style changes.
| }, | ||
| items: { table: { disable: true } }, | ||
| menuArgs: { table: { disable: true } }, | ||
| triggerArgs: { table: { disable: true } }, |
There was a problem hiding this comment.
I go back and forth on the removal of the iconName control from the table. We have a story that demonstrates that users have the ability to change the icon, but then removed the control so users can't experiment, so I'm split.
Anyways, I don't think it's blocking this PR from merging, but I did want to share some thoughts.
| triggerArgs: { | ||
| iconName: "More", | ||
| }, |
There was a problem hiding this comment.
I don't think this is necessary since we use this exact More icon in the default args.
| @@ -1,4 +1,4 @@ | |||
| import { Template as ActionMenu } from "@spectrum-css/actionmenu/stories/template.js"; | |||
| import { Template as ActionButton } from "@spectrum-css/actionbutton/stories/template.js"; | |||
There was a problem hiding this comment.
Does changing this from action menu to just an action button imply anything for SWC? I only ask because the Figma specs for coachmark do specify coachmark being composed with a menu. I don't think it does, but this markup change will be noted in the component analysis, so we'll just have to be sure that we review those docs and clarify that the SWC component as is should still use an action menu.
I also could be thinking too hard about it all.
There was a problem hiding this comment.
Yeah, I just removed the full implementation here for demonstration purposes but it doesn't change the end-result for SWC.

Description
This PR:
@spectrum-css/actionmenucomponent that composesActionButton,Popover, andMenuto present action lists from a trigger.@spectrum-css/actionbuttonand@spectrum-css/actiongroupto treat selection via.is-selectedas well as:where([aria-pressed="true"], [aria-expanded="true"])to cover more accessibility use-cases while keeping selector specificity low.@spectrum-css/menuto align with Spectrum 2 specifications and accessibility improvements.Design references:
Includes a changeset with the following bumps:
How and where has this been tested?
Action menustories (default, long-press, placements).Menustories for focus indicators, CJK line-height, external link/drill-in icons, thumbnails, and forced-colors behavior.Action buttonandAction groupselected visuals using.is-selected,[aria-pressed="true"], and[aria-expanded="true"].Validation steps
isOpenand confirm popover/menu spacing and placement reflect updates..is-selected, setaria-pressed="true", andaria-expanded="true"; confirm identical visuals due to:where(...)..is-selectedand ARIA attributes.Screenshots
To-do list
Notes for reviewers
:where([aria-pressed],[aria-expanded])to avoid specificity issues and broaden accessibility support.References
https://github.com/changesets/changesetshttps://www.figma.com/design/eoZHKJH9a3LJkHYCGt60Vb/S2-Token-specs?node-id=19758-3424