feat: implement Menu component - #738
Conversation
📖 Docs Preview🔗 Preview URL: https://ibm.github.io/carbon-components-ember/pr-previews/pr-738/ Built from commit 4cd9456 |
|
the docs preview for menu hangs. |
|
in docs preview the menu shows up in left corner. can it be contained to the docs root (shadow dom)? |
|
Thanks — both of those were the same root cause plus a docs-preview issue. Pushed The hang (
|
cbfdc73 to
3d1f2f1
Compare
|
menu is now in shadow dom, but sub menu (opened to the right) is not correctly positioned |
Implements Menu for parity with Carbon React: a context-menu-style component with MenuItem, MenuItemDivider, MenuItemGroup, MenuItemRadioGroup, and MenuItemSelectable, supporting nested submenus, keyboard navigation, and controlled/uncontrolled selection state. Closes #694 Signed-off-by: Patrick Pircher <patrick.pircher@ibm.com>
…r assertion, and fix menu-test to assert against the portaled DOM scanFeatures unconditionally reassigned the @Tracked hasIcons/ hasSelectableItems properties on every scan, which both retriggered its own MutationObserver in a loop and rewrote the class attribute during the same render computation that had already read it. Only assign when the computed value actually changes, and defer the initial scan to the next frame like positionMenu already does. menu-test.gts rendered the root Menu with its default @target (document.body) and asserted with the default qunit-dom context, which only searches the rendering-test container - not document.body, where the in-element portal actually places content. Every test now points @target at a dedicated container appended to the body and scopes assertions to it, mirroring the workaround already used in portal-test.gts. Signed-off-by: Patrick Pircher <patrick.pircher@ibm.com>
The observer watched its own `<ul>`'s attributes, so every `class` rewrite Ember performed for the `--with-icons`/`--with-selectable-items` modifier classes fed straight back into the observer callback. That callback set tracked state the same render had already consumed, which is a backtracking-rerender assertion in dev builds and an endless revalidation loop in production - the docs preview hanging. Items now register with the menu they belong to, the way Carbon's React items feed the context the classes are derived from, and this repo's own ProgressIndicator/Tabs do. `Menu` derives both classes from the registered items, so they stay reactive to items being added or removed and no longer depend on an icon's async SVG landing in the DOM. Also contains the Menu docs examples inside the preview: they pass a local element as `@target` so the menu renders in the preview's shadow root instead of escaping into `document.body`, where the preview's styles don't reach it and it showed up unstyled in the page's top left corner. Signed-off-by: Patrick Pircher <patrick.pircher@ibm.com>
3d1f2f1 to
4cd9456
Compare
Summary
Menufor parity with Carbon React: a context-menu-style component supporting nested submenus and keyboard navigation.MenuItem,MenuItemDivider,MenuItemGroup,MenuItemRadioGroup, andMenuItemSelectablesubcomponents, including controlled/uncontrolled selection state.Closes #694
Test plan
pnpm buildsucceedspnpm lintpassespnpm test— full suite passes, including new Menu tests