carbon-design-system / carbon

A design system built by IBM
https://www.carbondesignsystem.com
Apache License 2.0
7.6k stars 1.76k forks source link

[Feature Request]: Stop using a portal for `Menu` #16883

Open tay1orjones opened 1 week ago

tay1orjones commented 1 week ago

The problem

The Menu primitive uses a portal to render the ul list. This was added in https://github.com/carbon-design-system/carbon/pull/8829 to:

avoid it being misplaced, cut off or invisible in certain setups (such as the DataTable toolbar)

Those issues may be solved now by the new autoAlign feature using floating ui, https://github.com/carbon-design-system/carbon/issues/15521.

The primary reason for this is that it's a risk of failing WCAG 1.3.2: Meaningful Sequence (Level A.) Specifically, Failure of Success Criterion 1.3.2 due to changing the meaning of content by positioning information with CSS.

The solution

Explore removing the portal in favor of rendering the menu adjacent to the trigger in the DOM and determine if floating-ui solves all the use cases for positioning and overlaying wrt Menu. This includes MenuButton, OverflowMenu, ContextMenu, etc.

This could be put behind a flag for now and included by default in the next major.

Short of this https://github.com/carbon-design-system/carbon/issues/16882 should at least be fixed so the portal destination is configurable.

Examples

No response

Application/PAL

No response

Business priority

Low Priority = release date is not dependent on fix or not upcoming

Available extra resources

No response

Code of Conduct

github-actions[bot] commented 1 week ago

Thank you for submitting a feature request. Your proposal is open and will soon be triaged by the Carbon team.

If your proposal is accepted and the Carbon team has bandwidth they will take on the issue, or else request you or other volunteers from the community to work on this issue.