Skip to content

Commit 14d7b43

Browse files
Fedo Hagge-Kubatclaude
authored andcommitted
fix(a11y): WCAG 2.4.6 — add descriptive headings and section labels
- Add visually-hidden h1 with dashboard name to Dashboard Header - Add visually-hidden h1 with chart name to Explore/Chart Header - Add visually-hidden h1 to Home page and ChartCreation page - Fix ChartCreation heading hierarchy (h3 → h2) - Add sr-only h2 section headings for Filters and Dashboard Content areas - All headings use clip/sr-only pattern for screen readers only Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 5815665 commit 14d7b43

5 files changed

Lines changed: 71 additions & 3 deletions

File tree

‎superset-frontend/src/dashboard/components/DashboardBuilder/DashboardBuilder.tsx‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,18 @@ const StyledDashboardContent = styled.div<{
351351
`}
352352
`;
353353

354+
const SrOnlyH2 = styled.h2`
355+
position: absolute;
356+
width: 1px;
357+
height: 1px;
358+
padding: 0;
359+
margin: -1px;
360+
overflow: hidden;
361+
clip: rect(0, 0, 0, 0);
362+
white-space: nowrap;
363+
border: 0;
364+
`;
365+
354366
const ELEMENT_ON_SCREEN_OPTIONS = {
355367
threshold: [1],
356368
};
@@ -616,6 +628,8 @@ const DashboardBuilder = () => {
616628
return (
617629
<DashboardWrapper>
618630
{isVerticalFilterBarVisible && (
631+
<>
632+
<SrOnlyH2>{t('Filters')}</SrOnlyH2>
619633
<ResizableSidebar
620634
id={`dashboard:${dashboardId}`}
621635
enable={dashboardFiltersOpen}
@@ -625,6 +639,7 @@ const DashboardBuilder = () => {
625639
>
626640
{renderChild}
627641
</ResizableSidebar>
642+
</>
628643
)}
629644
<StyledHeader
630645
data-test="dashboard-header-wrapper"
@@ -649,6 +664,7 @@ const DashboardBuilder = () => {
649664
{renderDraggableContent}
650665
</Droppable>
651666
</StyledHeader>
667+
<SrOnlyH2>{t('Dashboard content')}</SrOnlyH2>
652668
<StyledContent fullSizeChartId={fullSizeChartId}>
653669
{!editMode &&
654670
!topLevelTabs &&

‎superset-frontend/src/dashboard/components/Header/index.tsx‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,18 @@ const actionButtonsStyle = (theme: SupersetTheme) => css`
177177
}
178178
`;
179179

180+
const SrOnlyH1 = styled.h1`
181+
position: absolute;
182+
width: 1px;
183+
height: 1px;
184+
padding: 0;
185+
margin: -1px;
186+
overflow: hidden;
187+
clip: rect(0, 0, 0, 0);
188+
white-space: nowrap;
189+
border: 0;
190+
`;
191+
180192
const StyledUndoRedoButton = styled(Button)`
181193
// TODO: check if we need this
182194
padding: 0;
@@ -827,6 +839,7 @@ const Header = (): JSX.Element => {
827839
data-test-id={dashboardInfo.id}
828840
className="dashboard-header-container"
829841
>
842+
<SrOnlyH1>{dashboardTitle || t('Dashboard')}</SrOnlyH1>
830843
<PageHeaderWithActions
831844
editableTitleProps={editableTitleProps}
832845
certificatiedBadgeProps={certifiedBadgeProps}

‎superset-frontend/src/explore/components/ExploreChartHeader/index.tsx‎

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ import {
3333
MatrixifyFormData,
3434
} from '@superset-ui/core';
3535
import { logging } from '@apache-superset/core/utils';
36-
import { css, SupersetTheme } from '@apache-superset/core/theme';
36+
import { css, styled, SupersetTheme } from '@apache-superset/core/theme';
3737
import { t } from '@apache-superset/core/translation';
3838
import { Icons } from '@superset-ui/core/components/Icons';
3939
import PropertiesModal from 'src/explore/components/PropertiesModal';
@@ -84,6 +84,18 @@ export interface ExploreChartHeaderProps {
8484
isSaveModalVisible?: boolean;
8585
}
8686

87+
const SrOnlyH1 = styled.h1`
88+
position: absolute;
89+
width: 1px;
90+
height: 1px;
91+
padding: 0;
92+
margin: -1px;
93+
overflow: hidden;
94+
clip: rect(0, 0, 0, 0);
95+
white-space: nowrap;
96+
border: 0;
97+
`;
98+
8799
const saveButtonStyles = (theme: SupersetTheme) => css`
88100
color: ${theme.colorPrimaryText};
89101
& > span[role='img'] {
@@ -272,6 +284,7 @@ export const ExploreChartHeader: FC<ExploreChartHeaderProps> = ({
272284

273285
return (
274286
<>
287+
<SrOnlyH1>{sliceName || t('Explore chart')}</SrOnlyH1>
275288
<PageHeaderWithActions
276289
editableTitleProps={{
277290
title: sliceName ?? '',

‎superset-frontend/src/pages/ChartCreation/index.tsx‎

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ const StyledContainer = styled.div`
8484
padding-right: ${theme.padding}px;
8585
padding-bottom: ${theme.padding}px;
8686
87-
h3 {
87+
h2 {
8888
padding-bottom: ${theme.paddingSM}px;
8989
}
9090
@@ -158,6 +158,18 @@ const StyledContainer = styled.div`
158158
`}
159159
`;
160160

161+
const SrOnlyH1 = styled.h1`
162+
position: absolute;
163+
width: 1px;
164+
height: 1px;
165+
padding: 0;
166+
margin: -1px;
167+
overflow: hidden;
168+
clip: rect(0, 0, 0, 0);
169+
white-space: nowrap;
170+
border: 0;
171+
`;
172+
161173
const StyledStepTitle = styled.span`
162174
${({ theme: { fontSize, fontWeightStrong } }) => `
163175
font-size: ${fontSize}px;
@@ -329,7 +341,8 @@ export class ChartCreation extends PureComponent<
329341

330342
return (
331343
<StyledContainer>
332-
<h3>{t('Create a new chart')}</h3>
344+
<SrOnlyH1>{t('Create a new chart')}</SrOnlyH1>
345+
<h2 aria-hidden="true">{t('Create a new chart')}</h2>
333346
<Steps direction="vertical" size="small">
334347
<Steps.Step
335348
title={<StyledStepTitle>{t('Choose a dataset')}</StyledStepTitle>}

‎superset-frontend/src/pages/Home/index.tsx‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,18 @@ interface LoadingProps {
7676

7777
const DEFAULT_TAB_ARR = ['dashboards', 'charts'];
7878

79+
const SrOnlyH1 = styled.h1`
80+
position: absolute;
81+
width: 1px;
82+
height: 1px;
83+
padding: 0;
84+
margin: -1px;
85+
overflow: hidden;
86+
clip: rect(0, 0, 0, 0);
87+
white-space: nowrap;
88+
border: 0;
89+
`;
90+
7991
const WelcomeContainer = styled.div`
8092
background: ${({ theme }) => theme.colorBgLayout};
8193
.ant-row.menu {
@@ -350,6 +362,7 @@ function Welcome({ user, addDangerToast }: WelcomeProps) {
350362
<SubMenu {...menuData} />
351363
)}
352364
<WelcomeContainer>
365+
<SrOnlyH1>{t('Home')}</SrOnlyH1>
353366
{WelcomeMessageExtension && <WelcomeMessageExtension />}
354367
{WelcomeTopExtension && <WelcomeTopExtension />}
355368
{WelcomeMainExtension && <WelcomeMainExtension />}

0 commit comments

Comments
 (0)