Skip to content

Commit 7123ab7

Browse files
authored
Merge pull request #31 from edx/copilot/update-unit-title-heading
feat: change Unit title from h3 to h1 for accessibility compliance
2 parents c13f118 + bfefacb commit 7123ab7

3 files changed

Lines changed: 19 additions & 1 deletion

File tree

src/courseware/course/sequence/Unit/index.test.jsx

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,19 @@ describe('<Unit />', () => {
8484

8585
expect(nextButton).toBeVisible();
8686
});
87+
88+
// Test for accessibility compliance: unit title must be an h1 (heading level 1) as the page's primary heading
89+
// for screen reader and accessibility compliance.
90+
// See: https://edx.readthedocs.io/projects/open-edx-building-and-running-a-course/en/latest/course_components/create_html_component.html#the-visual-editor
91+
// JIRA: https://2u-internal.atlassian.net/browse/AU-2135
92+
it('renders unit title as h1 heading for accessibility', () => {
93+
renderComponent(defaultProps);
94+
95+
const unitTitle = screen.getByRole('heading', { level: 1 });
96+
97+
expect(unitTitle).toBeInTheDocument();
98+
expect(unitTitle.tagName).toBe('H1');
99+
});
87100
});
88101

89102
describe('UnitSuspense', () => {

src/index.scss

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,11 @@
302302
padding-left: 40px;
303303
padding-right: 40px;
304304
}
305+
306+
// Unit title is styled as an H3
307+
.unit-title {
308+
font-size: var(--pgn-typography-font-size-h3-base);
309+
}
305310
}
306311

307312
.unit-iframe-wrapper {

src/plugin-slots/UnitTitleSlot/index.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ const UnitTitleSlot = ({
2727
>
2828
<div className="d-flex justify-content-between">
2929
<div className="mb-0">
30-
<h3 className="h3">{unit.title}</h3>
30+
<h1 className="unit-title">{unit.title}</h1>
3131
</div>
3232
{isEnabledOutlineSidebar && renderUnitNavigation(true)}
3333
</div>

0 commit comments

Comments
 (0)