Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ export const InfoTooltip = ({
&&&:active {
box-shadow: none;
background: none;
outline: none;
color: ${theme.colorTextTertiary};
}
${onClick ? 'cursor: pointer;' : ''}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
* specific language governing permissions and limitations
* under the License.
*/
/// <reference types="@emotion/jest" />
import { supersetTheme } from '@apache-superset/core/theme';
import { render, screen, userEvent } from 'spec/helpers/testing-library';
import { Indicator } from 'src/dashboard/components/nativeFilters/selectors';
import FilterIndicator from '.';
Expand Down Expand Up @@ -81,3 +83,14 @@ test('Should render with default props', async () => {
screen.getByRole('button', { name: 'Vaccine Approach' }),
);
});

test('Shows a visible focus ring when focused with the keyboard', () => {
const props = createProps();
render(<FilterIndicator {...props} />);

expect(
screen.getByRole('button', { name: 'search Vaccine Approach' }),
).toHaveStyleRule('outline', `2px solid ${supersetTheme.colorPrimary}`, {
target: ':focus-visible',
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,11 @@ export const FilterItem = styled.button`
border: 0;
}

&:focus-visible {
outline: 2px solid ${theme.colorPrimary};
outline-offset: -2px;
}

& i svg {
opacity: 35%;
margin-right: ${theme.sizeUnit}px;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
* specific language governing permissions and limitations
* under the License.
*/
/// <reference types="@emotion/jest" />
import { supersetTheme } from '@apache-superset/core/theme';
import {
cleanup,
render,
Expand Down Expand Up @@ -263,3 +265,15 @@ test('updates search text when typing in the search input', async () => {

expect(searchInput).toHaveValue('Chart');
});

test('tree node titles show a visible keyboard focus ring', () => {
const { container } = render(<FilterScopeSelector {...defaultProps} />, {
useRedux: true,
});

expect(container.querySelector('.filters-scope-selector')).toHaveStyleRule(
'outline',
`2px solid ${supersetTheme.colorPrimary}`,
{ target: '.rct-node-clickable:focus-visible' },
);
});
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,12 @@ const ScopeSelector = styled.div`
label:active {
background: none !important;
}

/* react-checkbox-tree.css removes the focus outline on node titles */
.rct-node-clickable:focus-visible {
outline: 2px solid ${theme.colorPrimary};
outline-offset: -2px;
}
}

.multi-edit-mode {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@
* specific language governing permissions and limitations
* under the License.
*/
/// <reference types="@emotion/jest" />
import { ComponentProps } from 'react';
import { supersetTheme } from '@apache-superset/core/theme';
import {
render,
screen,
Expand All @@ -26,7 +28,9 @@ import {
} from 'spec/helpers/testing-library';
import { Comparator } from '@superset-ui/chart-controls';
import { GenericDataType } from '@apache-superset/core/common';
import ConditionalFormattingControl from './ConditionalFormattingControl';
import ConditionalFormattingControl, {
CloseButton,
} from './ConditionalFormattingControl';
import { ConditionalFormattingConfig } from './types';

const columnOptions = [
Expand Down Expand Up @@ -437,3 +441,12 @@ test('reports adding and then removing a formatter on an unset value', async ()
await userEvent.click(screen.getByLabelText('close'));
expect(lastChange(onChange)).toEqual([]);
});

test('close button shows a visible focus ring when focused with the keyboard', () => {
render(<CloseButton aria-label="Remove" />);
expect(screen.getByRole('button', { name: 'Remove' })).toHaveStyleRule(
'outline',
`2px solid ${supersetTheme.colorPrimary}`,
{ target: ':focus-visible' },
);
});
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,11 @@ export const CloseButton = styled.button`
outline: none;
border-bottom-left-radius: 3px;
border-top-left-radius: 3px;

&:focus-visible {
outline: 2px solid ${theme.colorPrimary};
outline-offset: -2px;
}
`}
`;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,15 @@
* specific language governing permissions and limitations
* under the License.
*/
/// <reference types="@emotion/jest" />
import {
ChartLabel,
ChartMetadata,
ChartPlugin,
Preset,
VizType,
} from '@superset-ui/core';
import { supersetTheme } from '@apache-superset/core/theme';
import {
render,
cleanup,
Expand Down Expand Up @@ -437,4 +439,13 @@ describe('VizTypeControl', () => {
).toBeInTheDocument();
});
});

test('Category tabs show a visible keyboard focus ring', async () => {
await waitForRenderWrapper();
expect(screen.getByRole('tab', { name: 'All charts' })).toHaveStyleRule(
'outline',
`2px solid ${supersetTheme.colorPrimary}`,
{ target: ':focus-visible' },
);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,10 @@ const SelectorLabel = styled.button`
position: relative;
color: ${theme.colorText};

&:focus {
outline: initial;
/* Outset ring so it stays visible on the colorPrimary-filled selected label */
&:focus-visible {
outline: 2px solid ${theme.colorPrimary};
outline-offset: 2px;
}

&.selected {
Expand Down Expand Up @@ -277,7 +279,12 @@ const thumbnailContainerCss = (theme: SupersetTheme) => css`
font: inherit;
cursor: pointer;
width: ${theme.sizeUnit * THUMBNAIL_GRID_UNITS}px;
outline: none; /* Remove focus outline to show only selected state */
outline: none;

&:focus-visible {
outline: 2px solid ${theme.colorPrimary};
outline-offset: 2px;
}

img {
min-width: ${theme.sizeUnit * THUMBNAIL_GRID_UNITS}px;
Expand Down
Loading