Skip to content

Commit 7e672a6

Browse files
sadpandajoeFedo Hagge-Kubatclaude
authored
fix(a11y): show a visible keyboard focus ring on interactive controls (#46396)
Co-authored-by: Fedo Hagge-Kubat <fedo.hagge-kubat@aitema.de> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
1 parent d784db7 commit 7e672a6

9 files changed

Lines changed: 78 additions & 5 deletions

File tree

‎superset-frontend/packages/superset-ui-core/src/components/InfoTooltip/index.tsx‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,6 @@ export const InfoTooltip = ({
9797
&&&:active {
9898
box-shadow: none;
9999
background: none;
100-
outline: none;
101100
color: ${theme.colorTextTertiary};
102101
}
103102
${onClick ? 'cursor: pointer;' : ''}

‎superset-frontend/src/dashboard/components/FiltersBadge/FilterIndicator/FilterIndicator.test.tsx‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
* specific language governing permissions and limitations
1717
* under the License.
1818
*/
19+
/// <reference types="@emotion/jest" />
20+
import { supersetTheme } from '@apache-superset/core/theme';
1921
import { render, screen, userEvent } from 'spec/helpers/testing-library';
2022
import { Indicator } from 'src/dashboard/components/nativeFilters/selectors';
2123
import FilterIndicator from '.';
@@ -81,3 +83,14 @@ test('Should render with default props', async () => {
8183
screen.getByRole('button', { name: 'Vaccine Approach' }),
8284
);
8385
});
86+
87+
test('Shows a visible focus ring when focused with the keyboard', () => {
88+
const props = createProps();
89+
render(<FilterIndicator {...props} />);
90+
91+
expect(
92+
screen.getByRole('button', { name: 'search Vaccine Approach' }),
93+
).toHaveStyleRule('outline', `2px solid ${supersetTheme.colorPrimary}`, {
94+
target: ':focus-visible',
95+
});
96+
});

‎superset-frontend/src/dashboard/components/FiltersBadge/Styles.tsx‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,11 @@ export const FilterItem = styled.button`
8787
border: 0;
8888
}
8989
90+
&:focus-visible {
91+
outline: 2px solid ${theme.colorPrimary};
92+
outline-offset: -2px;
93+
}
94+
9095
& i svg {
9196
opacity: 35%;
9297
margin-right: ${theme.sizeUnit}px;

‎superset-frontend/src/dashboard/components/filterscope/FilterScopeSelector.test.tsx‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
* specific language governing permissions and limitations
1717
* under the License.
1818
*/
19+
/// <reference types="@emotion/jest" />
20+
import { supersetTheme } from '@apache-superset/core/theme';
1921
import {
2022
cleanup,
2123
render,
@@ -263,3 +265,15 @@ test('updates search text when typing in the search input', async () => {
263265

264266
expect(searchInput).toHaveValue('Chart');
265267
});
268+
269+
test('tree node titles show a visible keyboard focus ring', () => {
270+
const { container } = render(<FilterScopeSelector {...defaultProps} />, {
271+
useRedux: true,
272+
});
273+
274+
expect(container.querySelector('.filters-scope-selector')).toHaveStyleRule(
275+
'outline',
276+
`2px solid ${supersetTheme.colorPrimary}`,
277+
{ target: '.rct-node-clickable:focus-visible' },
278+
);
279+
});

‎superset-frontend/src/dashboard/components/filterscope/FilterScopeSelector.tsx‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,12 @@ const ScopeSelector = styled.div`
320320
label:active {
321321
background: none !important;
322322
}
323+
324+
/* react-checkbox-tree.css removes the focus outline on node titles */
325+
.rct-node-clickable:focus-visible {
326+
outline: 2px solid ${theme.colorPrimary};
327+
outline-offset: -2px;
328+
}
323329
}
324330
325331
.multi-edit-mode {

‎superset-frontend/src/explore/components/controls/ConditionalFormattingControl/ConditionalFormattingControl.test.tsx‎

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@
1616
* specific language governing permissions and limitations
1717
* under the License.
1818
*/
19+
/// <reference types="@emotion/jest" />
1920
import { ComponentProps } from 'react';
21+
import { supersetTheme } from '@apache-superset/core/theme';
2022
import {
2123
render,
2224
screen,
@@ -26,7 +28,9 @@ import {
2628
} from 'spec/helpers/testing-library';
2729
import { Comparator } from '@superset-ui/chart-controls';
2830
import { GenericDataType } from '@apache-superset/core/common';
29-
import ConditionalFormattingControl from './ConditionalFormattingControl';
31+
import ConditionalFormattingControl, {
32+
CloseButton,
33+
} from './ConditionalFormattingControl';
3034
import { ConditionalFormattingConfig } from './types';
3135

3236
const columnOptions = [
@@ -437,3 +441,12 @@ test('reports adding and then removing a formatter on an unset value', async ()
437441
await userEvent.click(screen.getByLabelText('close'));
438442
expect(lastChange(onChange)).toEqual([]);
439443
});
444+
445+
test('close button shows a visible focus ring when focused with the keyboard', () => {
446+
render(<CloseButton aria-label="Remove" />);
447+
expect(screen.getByRole('button', { name: 'Remove' })).toHaveStyleRule(
448+
'outline',
449+
`2px solid ${supersetTheme.colorPrimary}`,
450+
{ target: ':focus-visible' },
451+
);
452+
});

‎superset-frontend/src/explore/components/controls/ConditionalFormattingControl/ConditionalFormattingControl.tsx‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,11 @@ export const CloseButton = styled.button`
6464
outline: none;
6565
border-bottom-left-radius: 3px;
6666
border-top-left-radius: 3px;
67+
68+
&:focus-visible {
69+
outline: 2px solid ${theme.colorPrimary};
70+
outline-offset: -2px;
71+
}
6772
`}
6873
`;
6974

‎superset-frontend/src/explore/components/controls/VizTypeControl/VizTypeControl.test.tsx‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,15 @@
1616
* specific language governing permissions and limitations
1717
* under the License.
1818
*/
19+
/// <reference types="@emotion/jest" />
1920
import {
2021
ChartLabel,
2122
ChartMetadata,
2223
ChartPlugin,
2324
Preset,
2425
VizType,
2526
} from '@superset-ui/core';
27+
import { supersetTheme } from '@apache-superset/core/theme';
2628
import {
2729
render,
2830
cleanup,
@@ -437,4 +439,13 @@ describe('VizTypeControl', () => {
437439
).toBeInTheDocument();
438440
});
439441
});
442+
443+
test('Category tabs show a visible keyboard focus ring', async () => {
444+
await waitForRenderWrapper();
445+
expect(screen.getByRole('tab', { name: 'All charts' })).toHaveStyleRule(
446+
'outline',
447+
`2px solid ${supersetTheme.colorPrimary}`,
448+
{ target: ':focus-visible' },
449+
);
450+
});
440451
});

‎superset-frontend/src/explore/components/controls/VizTypeControl/VizTypeGallery.tsx‎

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -174,8 +174,10 @@ const SelectorLabel = styled.button`
174174
position: relative;
175175
color: ${theme.colorText};
176176
177-
&:focus {
178-
outline: initial;
177+
/* Outset ring so it stays visible on the colorPrimary-filled selected label */
178+
&:focus-visible {
179+
outline: 2px solid ${theme.colorPrimary};
180+
outline-offset: 2px;
179181
}
180182
181183
&.selected {
@@ -277,7 +279,12 @@ const thumbnailContainerCss = (theme: SupersetTheme) => css`
277279
font: inherit;
278280
cursor: pointer;
279281
width: ${theme.sizeUnit * THUMBNAIL_GRID_UNITS}px;
280-
outline: none; /* Remove focus outline to show only selected state */
282+
outline: none;
283+
284+
&:focus-visible {
285+
outline: 2px solid ${theme.colorPrimary};
286+
outline-offset: 2px;
287+
}
281288
282289
img {
283290
min-width: ${theme.sizeUnit * THUMBNAIL_GRID_UNITS}px;

0 commit comments

Comments
 (0)