Skip to content

fix(NavList): merge sx and non-sx scenarios #6264

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

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/kind-pants-march.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@primer/react': patch
---

Update NavList.Group to render divider when `sx` is provided
14 changes: 3 additions & 11 deletions packages/react/src/NavList/NavList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -285,20 +285,11 @@ export type NavListGroupProps = React.HTMLAttributes<HTMLLIElement> & {
title?: string
} & SxProp

const defaultSx = {}
const Group: React.FC<NavListGroupProps> = ({title, children, sx: sxProp = defaultSx, ...props}) => {
if (sxProp !== defaultSx) {
return (
<Box sx={sxProp} as="li" data-component="ActionList.Group">
{title ? <ActionList.GroupHeading>{title}</ActionList.GroupHeading> : null}
{children}
</Box>
)
}
function Group({title, children, sx, ...rest}: NavListGroupProps) {
return (
<>
<ActionList.Divider />
<ActionList.Group {...props}>
<ActionList.Group {...rest} sx={sx}>
{/* Setting up the default value for the heading level. TODO: API update to give flexibility to NavList.Group title's heading level */}
{title ? (
<ActionList.GroupHeading as="h3" data-component="ActionList.GroupHeading">
Expand All @@ -310,6 +301,7 @@ const Group: React.FC<NavListGroupProps> = ({title, children, sx: sxProp = defau
</>
)
}

// ----------------------------------------------------------------------------
// NavList.GroupExpand

Expand Down
Loading