-
Notifications
You must be signed in to change notification settings - Fork 15
feat(container-menu)!: Add getAnchorProps for explicit anchor handling #695
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
useMenu no longer tracks selected link state internally. Consumers must now...
How does this impact react-components with respect to a breaking change?
| }: MenuReturnValue & UseMenuProps) => { | ||
| const selectedValues = selection.map(item => item.value); | ||
|
|
||
| React.useEffect(() => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nit] prefer import { useEffect } from 'react'; similar to useRef above
No impact. The PR introducing navigational menu items was never merged. 😌 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From the story deployment, it appears I can set initial selected to true for the anchor item in the uncontrolled demo. But the same does not appear to be true for the controlled demo: https://68224a63b85f0898b77419aa--zendeskgarden-react-containers.netlify.app/?path=/story/packages-menu--controlled&args=items[4].external:!true;items[4].selected:!true;isExpanded:!true;focusedValue:plant-04
|
This spec tests that use-case.
Note: By design, default selected items are only applied on initial mount. Subsequent changes to the items array won't affect the selection. If you're updating default selections and selectedItems is set to null, make sure to rerun the story to see the changes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the clarification. LGTM

Description
This PR updates the
useMenuAPI by decoupling anchor-related logic fromgetItemProps. It introduces a newgetAnchorPropsgetter for handling anchor-specific attributes in navigational menus. This PR is to supersede #693.BREAKING CHANGES
getItemPropsno longer includes anchor-related props. UsegetAnchorPropsfor<a>tags.getItemPropsfor<li>-level attributes around anchor items.useMenuno longer tracks selected link state internally. Consumers must now:selected: true, orprops.selectedItems(overrides items selected by default)Details
getAnchorPropsbehavior:href.target="_blank"andrel="noreferrer noopener"whenexternalistrue.See zendeskgarden/react-components#2019 for implementation preview in
Menu.Checklist
npm start)