Skip to content

Commit b668d74

Browse files
colebemisbroccolinisoup
authored andcommitted
NavList: Fix group dividers (#3328)
* Fix NavLIst.Group dividers * Use first-of-type instead of first-child * Update snapshots and stories
1 parent 68aa629 commit b668d74

File tree

3 files changed

+27
-20
lines changed

3 files changed

+27
-20
lines changed

src/NavList/NavList.stories.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,18 @@ export const Simple: Story = () => (
2828

2929
export const WithGroup: Story = () => (
3030
<NavList>
31-
<NavList.Group title="Group title">
31+
<NavList.Group title="Group 1">
3232
<NavList.Item href="#" aria-current="page">
3333
Item 1
3434
</NavList.Item>
3535
<NavList.Item href="#">Item 2</NavList.Item>
3636
<NavList.Item href="#">Item 3</NavList.Item>
3737
</NavList.Group>
38+
<NavList.Group title="Group 2">
39+
<NavList.Item href="#">Item 4</NavList.Item>
40+
<NavList.Item href="#">Item 5</NavList.Item>
41+
<NavList.Item href="#">Item 6</NavList.Item>
42+
</NavList.Group>
3843
</NavList>
3944
)
4045

src/NavList/NavList.tsx

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -250,14 +250,16 @@ const defaultSx = {}
250250
// TODO: ref prop
251251
const Group: React.FC<NavListGroupProps> = ({title, children, sx: sxProp = defaultSx, ...props}) => {
252252
return (
253-
<Box as="li" sx={sxProp} {...props}>
253+
<>
254254
{/* Hide divider if the group is the first item in the list */}
255-
<ActionList.Divider as="div" sx={{'&:first-child': {display: 'none'}}} />
256-
{title && <ActionList.Heading title={title} />}
257-
<Box as="ul" sx={{paddingInlineStart: 0}}>
258-
{children}
255+
<ActionList.Divider sx={{'&:first-of-type': {display: 'none'}}} />
256+
<Box as="li" sx={sxProp} {...props}>
257+
{title && <ActionList.Heading title={title} />}
258+
<Box as="ul" sx={{paddingInlineStart: 0}}>
259+
{children}
260+
</Box>
259261
</Box>
260-
</Box>
262+
</>
261263
)
262264
}
263265

src/NavList/__snapshots__/NavList.test.tsx.snap

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,7 @@ exports[`NavList renders with groups 1`] = `
411411
list-style: none;
412412
}
413413
414-
.c2:first-child {
414+
.c2:first-of-type {
415415
display: none;
416416
}
417417
@@ -705,15 +705,15 @@ exports[`NavList renders with groups 1`] = `
705705
<ul
706706
class="c1"
707707
>
708+
<li
709+
aria-hidden="true"
710+
class="c2"
711+
data-component="ActionList.Divider"
712+
role="separator"
713+
/>
708714
<li
709715
class=""
710716
>
711-
<div
712-
aria-hidden="true"
713-
class="c2"
714-
data-component="ActionList.Divider"
715-
role="separator"
716-
/>
717717
<div
718718
class="c3"
719719
>
@@ -752,15 +752,15 @@ exports[`NavList renders with groups 1`] = `
752752
</li>
753753
</ul>
754754
</li>
755+
<li
756+
aria-hidden="true"
757+
class="c2"
758+
data-component="ActionList.Divider"
759+
role="separator"
760+
/>
755761
<li
756762
class=""
757763
>
758-
<div
759-
aria-hidden="true"
760-
class="c2"
761-
data-component="ActionList.Divider"
762-
role="separator"
763-
/>
764764
<div
765765
class="c3"
766766
>

0 commit comments

Comments
 (0)