gestalt
gestalt copied to clipboard
SideNavigation: Add a label property to onExpand
Adding an extra prop to remove hard-coding of label names.
Right now, we just pass back the boolean value of expanded are now. But SideNavigations can also be defined statically, meaning there's no good way to pass the label name or an identifier when handling the expand operation.
Summary
Changes:
onExpand: (args: { expanded: boolean }) => void;
to
onExpand: (args: { label:string, expanded: boolean }) => void;
And folks can use a generic method like this to maintain state. It's updated in the examples:
const handleOnExpand = ({ label, expanded }: { label: string, expanded: boolean }) => {
if (expanded) {
setExpandedElements([...expandedElements, label]);
} else {
setExpandedElements(expandedElements.filter((value) => value !== label));
}
};
<SideNavigationGroup label="content" onExpand={handleOnExpand} ... />
Checklist
- [ ] Added unit and Flow Tests
- [ ] Added documentation + accessibility tests
- [ ] Verified accessibility: keyboard & screen reader interaction
- [ ] Checked dark mode, responsiveness, and right-to-left support
- [ ] Checked stakeholder feedback (e.g. Gestalt designers)
Deploy Preview for gestalt ready!
Name | Link |
---|---|
Latest commit | 99baccff9d4dcfcab4cd5ed0b577d3ba604b0dbd |
Latest deploy log | https://app.netlify.com/sites/gestalt/deploys/659ee465fedd0e00085bf0c6 |
Deploy Preview | https://deploy-preview-3351--gestalt.netlify.app |
Preview on mobile | Toggle QR Code...Use your smartphone camera to open QR code link. |
To edit notification comments on pull requests, go to your Netlify site configuration.