Repository navigation
feat(menu-separator): phases 2 to 7 migration - #6893
blunteshwar wants to merge 14 commits into
Conversation
|
📚 Branch Preview Links🔍 Gen1 Visual Regression Test ResultsWhen a visual regression test fails (or has previously failed while working on this branch), its results can be found in the following URLs:
Deployed to Azure Blob Storage: If the changes are expected, update the |
| block-size: var(--_swc-menu-separator-thickness); | ||
| margin-block: max(0px, calc((token("menu-item-section-divider-height") - var(--_swc-menu-separator-thickness)) / 2)); | ||
| margin-inline: token("base-padding-horizontal-medium"); | ||
| background-color: token("gray-200"); |
There was a problem hiding this comment.
Revisit this as it might not meet the plan's contrast requirement. menu uses background-layer-2-color. Kindly use a design-approved token pairing that meets the requirement, or explicitly revise the grouping design and accessibility requirement.
There was a problem hiding this comment.
Fixed in 2a68285. The line was gray-200, about 1.3:1 against the menu surface. It now uses gray-500, the lightest gray that reaches 3:1 against background-layer-2-color in both themes (about 3.2:1 light, 3.1:1 dark). This is heavier than the Figma line, so design still needs to confirm the token pairing.
| ### 1. Rename the element | ||
|
|
||
| ```html | ||
| <!-- Before --> | ||
| <sp-menu-divider></sp-menu-divider> | ||
|
|
||
| <!-- After --> | ||
| <swc-menu-separator></swc-menu-separator> | ||
| ``` |
There was a problem hiding this comment.
This is instructing the consumers to rename only the separator. An existing <sp-menu><sp-menu-divider>… becomes <sp-menu><swc-menu-separator>…, but only swc-menu supplies the new thickness property. The resulting line computes to 0px. The guide needs a parent-menu migration prerequisite and a complete composition example, including moving separators out of menu groups. Also reconcile the claim at line 78 that there are no public custom properties with the shipped @cssprop --swc-menu-separator-thickness.
There was a problem hiding this comment.
Fixed in 2a68285. The guide now makes migrating the parent menu the first step and explains that a separator outside swc-menu computes to 0px. It adds a before/after composition that moves the separator out of a menu group. The "no public custom properties" line is replaced with a note that --swc-menu-separator-thickness is set by swc-menu and is not a consumer styling API. swc-menu-group hasn't shipped, so the example flattens the group.
| const root = await gotoStory( | ||
| page, | ||
| 'components-menu-separator--overview', | ||
| 'swc-menu-separator' | ||
| ); | ||
| await expect(root).toMatchAriaSnapshot(` | ||
| - separator | ||
| `); | ||
| }); | ||
|
|
||
| test('should expose a single separator in anatomy', async ({ page }) => { | ||
| const root = await gotoStory( | ||
| page, | ||
| 'components-menu-separator--anatomy', | ||
| 'swc-menu-separator' | ||
| ); | ||
| await expect(root).toMatchAriaSnapshot(` | ||
| - separator |
There was a problem hiding this comment.
This snapshots the entire Storybook root using only - separator. This just proves its presence but we are not actually testing its placement between menu items. Please assert the menu subtree and separator count explicitly.
There was a problem hiding this comment.
Fixed in 2a68285. The spec now asserts the swc-menu subtree (menuitem Cut, menuitem Copy, separator, menuitem Delete) and exactly one separator for the overview, anatomy and accessibility stories. It also asserts the separator is a direct child of swc-menu. I haven't run it locally because it needs Storybook, so CI will be the first run.
…uide, and a11y spec
| // Placeholder rows: `swc-menu-item` has not shipped yet. | ||
| const renderInMenu = (id: string) => html` | ||
| <swc-button id="${id}-trigger">Edit</swc-button> | ||
| <swc-menu open for="${id}-trigger"> |
There was a problem hiding this comment.
every story renders swc-menu open, and since the menu is popover="auto" they close each other on the docs page. only the accessibility one stays open, so overview and anatomy just show the Edit button. could we set open only on overview like menu.stories.ts does and open the others from a play function?
| * Block margin centers the line in the 12px section-divider container | ||
| * (Q3: container height pending a spacing token update). */ | ||
| .swc-MenuSeparator { | ||
| --_swc-menu-separator-thickness: var(--swc-menu-separator-thickness, 0px); |
There was a problem hiding this comment.
with the 0px fallback the line disappears anywhere swc-menu isn't the direct parent (a wrapper, or a future submenu or action menu). what if we fall back to token("divider-thickness-medium") here? the menu can still set it
| * A menu separator separates groups of items inside a menu. | ||
| * | ||
| * @element swc-menu-separator | ||
| * @cssprop {Length} --swc-menu-separator-thickness - Line thickness. Set by the parent `swc-menu`; the separator does not define it. |
There was a problem hiding this comment.
@cssprop puts this in the API table, but the mdx says thickness isn't configurable and the migration guide says not to set it. could we pick one direction here and make the docs match?
| * | ||
| * @element swc-menu-separator | ||
| * @cssprop {Length} --swc-menu-separator-thickness - Line thickness. Set by the parent `swc-menu`; the separator does not define it. | ||
| * @since 2.0.0-beta.1 |
There was a problem hiding this comment.
nit: packages are at 2.0.0-beta.7 already, so i think this should be the next version rather than beta.1
|
|
||
| Place a menu separator between groups of menu items, not before the first item or after the last. The separator is not interactive and does not receive focus. | ||
|
|
||
| Place it as a direct child of `swc-menu`, `swc-action-menu`, or a `swc-menu-item` submenu, never inside a `swc-menu-group`. The menu supplies the line thickness. `swc-menu-item` has not shipped yet, so the examples slot placeholder rows with `role="menuitem"`. |
There was a problem hiding this comment.
nit: I suspect these may come in soon, but swc-action-menu, swc-menu-item submenus and swc-menu-group haven't shipped yet, and the first two wouldn't set the thickness anyway since only swc-menu's ::slotted rule does. IDK if we should move this to an upcoming features section for now?
| ); | ||
|
|
||
| await step('exposes role="separator" on the host', async () => { | ||
| expect(separator.getAttribute('role')).toBe('separator'); |
There was a problem hiding this comment.
small one, the sibling tests pass a message as the 2nd arg to expect() (the testing pr checklist asks for it too)
|
|
||
| | Area | Spectrum 1 | Spectrum 2 | | ||
| | --------- | --------------------------------- | --------------------------------------------------- | | ||
| | Role | `role="separator"`, overridable | `role="separator"`, set on the host and fixed | |
There was a problem hiding this comment.
gen1 also overwrites the role in firstUpdated, so i don't think "overridable" is right. this row could probably go
| | Role | `role="separator"`, overridable | `role="separator"`, set on the host and fixed | | ||
| | Placement | Allowed anywhere inside `sp-menu` | Place it between groups of menu items inside a menu | | ||
|
|
||
| ## Migration steps |
There was a problem hiding this comment.
the guide template uses ## Update your code, ### Removed in Spectrum 2, a ## Styling section with the --mod-* and internals callouts, and a ## Checklist. could we line it up with the badge and divider guides? steps 1 and 4 also need a before/after snippet
| | --- | ----------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | ||
| | Q1 | Standalone `swc-menu-separator`; do not reuse `swc-divider`. | Direction confirmed by blunteshwar (PR author) in this PR. nikkimk made the earlier call (Menu plan Q14, reuse `swc-divider`), so her review of the revised decision is still pending. Consistent with the menu-separator accessibility analysis. Supersedes Menu plan Q14. The Menu plan (Q14, Q15, Q21, Phase B) is updated to match. | | ||
| | Q6 | Use the Medium divider thickness (2px). | Figma Divider frame (node 9233:4610): Small 1px, Medium 2px, Large 4px. The Menu frame draws 2px. 1st-gen also defaults to medium. The Spectrum CSS story passing `size: "s"` does not match Figma. | | ||
| | Q2 | The core base extends `SpectrumElement`, not `DividerBase`. | Implemented in Phase 2 and 3 as the recommended option. `DividerBase` carries `size`, `vertical` and `staticColor`, which the separator must not expose. The duplicated line CSS is small (Q5). Pending reviewer confirmation. | |
There was a problem hiding this comment.
Q2 and Q8 both say pending confirmation, so maybe keep them in open questions until someone confirms? "User confirmation needed" (line 173) also still asks us to pick Q2
| ::slotted(swc-menu-separator) { | ||
| --swc-menu-separator-thickness: token("divider-thickness-medium"); | ||
|
|
||
| padding: 0; |
There was a problem hiding this comment.
nit: if the placeholder rule below targeted ::slotted(swc-menu-item) we wouldn't need this reset
Description
Phases 2 to 7 of the
swc-menu-separatormigration (Epic SWC-2668), combined into one PR. Targets themenu-separator-migrationfeature branch.MenuSeparatorBasein core, the swc element, and the core package exports.role="separator"set inconnectedCallback; no properties, slots or events. The 1st-gen deprecations for B1 to B3 are deferred (Q4).swc-menusets--swc-menu-separator-thicknesstodivider-thickness-mediumon::slotted(swc-menu-separator). The separator centers the line in the 12pxmenu-item-section-divider-heightcontainer, usesbase-padding-horizontal-mediumfor inline margin, and supports forced colors. A separator outside a menu renders a 0px line.toMatchAriaSnapshotspec.menu-separator.mdx,migration-guide.mdx, anAccessibilitystory and a gen2 changeset.Alignment with the merged plan
Re-checked against the plan merged in #6895:
swc-menu-separatoris now inMENU_ALLOWED_CHILDREN, soswc-menuno longer warns about it. The Menu JSDoc and docs no longer refer toswc-divideras the separator (Q1).--swc-menu-separator-thickness, whichswc-menusets, is documented with@cssprop, as the plan expects for the one reviewed property.InMenustory, a docs example and a test that checks the 2px thickness comes from the menu and that the separator is not focusable.Open items
margin-inlineusesbase-padding-horizontal-mediumbecausemenu-item-label-inline-edge-to-contentis not intokens.css. Needs design confirmation.swc-menu-itemandswc-menu-groupare deferred.Validation
yarn lint:gen2: passedyarn workspace @spectrum-web-components/gen2 build: passednpx vitest --run --project storybook menu-separator: passed (menu-separatorandmenu, 46 tests)