Skip to content

Commit

Permalink
2909 splitpagelayoutpane accepts an id but doesnt apply it (#2922)
Browse files Browse the repository at this point in the history
* test(SplitPageLayout): added failing test to fix

* fix(PageLayout): conditionally include `id` prop

* chore: added changeset

* docs(SplitPageLayout): updated story
  • Loading branch information
green6erry authored Mar 6, 2023
1 parent 527d32c commit 7140ac8
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/rotten-hats-wonder.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@primer/react': patch
---

Updated PageLayout.Pane to conditionally include id prop
1 change: 1 addition & 0 deletions src/PageLayout/PageLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -736,6 +736,7 @@ const Pane = React.forwardRef<HTMLDivElement, React.PropsWithChildren<PageLayout
'--pane-max-width-diff': '959px',
},
})}
{...(id && {id: paneId})}
>
{resizable && (
<VisuallyHidden>
Expand Down
6 changes: 6 additions & 0 deletions src/SplitPageLayout/SplitPageLayout.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,11 @@ const meta: Meta = {
control: {type: 'radio'},
table: {category: 'Pane props'},
},
'Pane.id': {
type: 'string',
defaultValue: 'customId',
table: {category: 'Pane props'},
},
'Pane.position.narrow': {
type: {
name: 'enum',
Expand Down Expand Up @@ -351,6 +356,7 @@ const Template: Story = args => (
regular: args['Pane.hidden.regular'],
wide: args['Pane.hidden.wide'],
}}
id={args['Pane.id']}
>
<Placeholder height={args['Pane placeholder height']} label="Pane" />
</SplitPageLayout.Pane>
Expand Down
15 changes: 15 additions & 0 deletions src/SplitPageLayout/SplitPageLayout.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,21 @@ describe('SplitPageLayout', () => {
</SplitPageLayout>
</ThemeProvider>,
)

expect(container).toMatchSnapshot()
})

it('renders Pane with a custom ID', () => {
const {getByText} = render(
<ThemeProvider>
<SplitPageLayout>
<SplitPageLayout.Pane id="customId">Pane Content</SplitPageLayout.Pane>
</SplitPageLayout>
</ThemeProvider>,
)

const pane = getByText('Pane Content')

expect(pane.getAttribute('id')).toBe('customId')
})
})

0 comments on commit 7140ac8

Please sign in to comment.