Skip to content

Commit

Permalink
SectionHeader improvement
Browse files Browse the repository at this point in the history
  • Loading branch information
haworku committed Jan 13, 2024
1 parent 47e6022 commit 1748cdd
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@
margin-top: 17.5px;
}
}

h2 {
word-wrap: 'break-word';
}
}

.summarySectionHeaderBorder {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ describe('SectionHeader', () => {
screen.getByRole('link', { name: 'Edit Page 2' })
).toHaveAttribute('href', '/some-edit-path')
})

it('respects the hideBorder prop', () => {
renderWithProviders(
<SectionHeader header="This is a section" hideBorder />
Expand All @@ -51,4 +52,12 @@ describe('SectionHeader', () => {
.closest('div')
).not.toHaveClass('summarySectionHeaderBorder')
})

it('does not render invisible zero-width space character in accesible name', () => {
renderWithProviders(<SectionHeader header="THIS-IS-123-456-67-RATE" />)

expect(
screen.getByRole('heading', { name: 'THIS-IS-123-456-67-RATE' })
).toHaveAccessibleName('THIS-IS-123-456-67-RATE')
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ export const SectionHeader = ({
return (
<div className={classes} id={sectionId}>
<div className={styles.primaryDiv}>
<h2 id={headerId}>{header}</h2>
<h2 id={headerId} style={{ wordWrap: 'break-word' }}>
{header}
</h2>
{subHeaderComponent}
</div>
<div>
Expand Down

0 comments on commit 1748cdd

Please sign in to comment.