Skip to content

fix(menu): Use package import for sp-menu-divider registration#6420

Open
Govind-gupta75 wants to merge 5 commits into
adobe:mainfrom
Govind-gupta75:menu-divider-import-fix
Open

fix(menu): Use package import for sp-menu-divider registration#6420
Govind-gupta75 wants to merge 5 commits into
adobe:mainfrom
Govind-gupta75:menu-divider-import-fix

Conversation

@Govind-gupta75

Copy link
Copy Markdown

Menu.ts registers via a relative side-effect import. In build systems that alias @spectrum-web-components/* packages (for example UXP wrappers), that relative path can resolve to a different module instance than the package export consumers use, causing duplicate custom element registration.

This follows the same fix applied in #3225 for MenuGroup, DialogBase, DialogWrapper, and Table.

Before

import '@spectrum-web-components/icons-ui/icons/sp-icon-arrow500.js';
import '../sp-menu-divider.js';

After

import '@spectrum-web-components/icons-ui/icons/sp-icon-arrow500.js';
// Leveraged in build systems that use aliasing to prevent multiple registrations: https://github.com/adobe/spectrum-web-components/pull/3225
import '@spectrum-web-components/menu/sp-menu-divider.js';

Problem
When extending SWC components in a wrapper layer and aliasing package paths (for example '@spectrum-web-components/menu': '@swc-uxp-internal/menu'), a relative import like ../sp-menu-divider.js may load the registration file from a different module graph than @spectrum-web-components/menu/sp-menu-divider.js. That can trigger:

NotSupportedError: Failed to execute 'define' on 'CustomElementRegistry':
the name "sp-menu-divider" has already been used with this registry

Motivation and context
Aligns Menu.ts with MenuGroup.ts, which already uses @spectrum-web-components/menu/sp-menu.js with the PR #3225 comment.
Ensures aliased/webpack-based builds register sp-menu-divider once.
No API or visual behavior change; import path only.
Related issue(s)
Related: #3225

Screenshots (if appropriate)


Author's checklist

  • I have read the CONTRIBUTING and PULL_REQUESTS documents.
  • I have reviewed at the Accessibility Practices for this feature, see: Aria Practices
  • I have added automated tests to cover my changes.
  • I have included a well-written changeset if my change needs to be published.
  • I have included updated documentation if my change required it.

Reviewer's checklist

  • Includes a Github Issue with appropriate flag or Jira ticket number without a link
  • Includes thoughtfully written changeset if changes suggested include patch, minor, or major features
  • Automated tests cover all use cases and follow best practices for writing
  • Validated on all supported browsers
  • All VRTs are approved before the author can update Golden Hash

Manual review test cases

  • Descriptive Test Statement

    1. Go here
    2. Do this action
    3. Expect this result
  • Descriptive Test Statement

    1. Go here
    2. Do this action
    3. Expect this result

Device review

  • Did it pass in Desktop?
  • Did it pass in (emulated) Mobile?
  • Did it pass in (emulated) iPad?

Accessibility testing checklist

Required: Complete each applicable item and document your testing steps (replace the placeholders with your component-specific instructions).

  • Keyboard (required — document steps below) — What to test for: Focus order is logical; Tab reaches the component and all interactive descendants; Enter/Space activate where appropriate; arrow keys work for tabs, menus, sliders, etc.; no focus traps; Escape dismisses when applicable; focus indicator is visible.

    1. Go here
    2. Do this action
    3. Expect this result
  • Screen reader (required — document steps below) — What to test for: Role and name are announced correctly; state changes (e.g. expanded, selected) are announced; labels and relationships are clear; no unnecessary or duplicate announcements.

    1. Go here
    2. Do this action
    3. Expect this result

@Govind-gupta75 Govind-gupta75 requested a review from a team as a code owner June 18, 2026 17:10
@changeset-bot

changeset-bot Bot commented Jun 18, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 1815c21

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@rubencarvalho rubencarvalho added the run_vrt Triggers the Chromatic VRT run for 2nd-gen label Jun 19, 2026
@coveralls

coveralls commented Jun 19, 2026

Copy link
Copy Markdown
Collaborator

Coverage Report for CI Build 27820598474

Warning

No base build found for commit 8551787 on main.
Coverage changes can't be calculated without a base build.
If a base build is processing, this comment will update automatically when it completes.

Coverage: 96.24%

Details

  • Patch coverage: 5 of 5 lines across 2 files are fully covered (100%).

Uncovered Changes

No uncovered changes found.

Coverage Regressions

Requires a base build to compare against. How to fix this →


Coverage Stats

Coverage Status
Relevant Lines: 39111
Covered Lines: 37840
Line Coverage: 96.75%
Relevant Branches: 6453
Covered Branches: 6011
Branch Coverage: 93.15%
Branches in Coverage %: Yes
Coverage Strength: 458.12 hits per line

💛 - Coveralls

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Contribution PRs from contributors run_vrt Triggers the Chromatic VRT run for 2nd-gen Status:Ready for review PR ready for review or re-review.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants