Unverified Commit cf0ad333 authored by Sebastian "Sebbie" Silbermann's avatar Sebastian "Sebbie" Silbermann Committed by GitHub

[dev-overlay] Fix outstanding a11y issues reported by Axe (#80290)

Adds labels to buttons that had no discernible text.

The automated tests via `test-storybook` seem to ignore `parameters.a11y.config.rules` so we can't leverage `test-storybook` in CI.
I can't even use `parameters.a11y.test`.

We need `parameters.a11y.config.rules` since some of the color-contrast violations are either minor (just slightly below threshold) or false-positives either because our background is misconfigured in automated tests, or background is not detected properly.
parent c151f896
...@@ -18,6 +18,26 @@ const preview: Preview = { ...@@ -18,6 +18,26 @@ const preview: Preview = {
parameters: { parameters: {
a11y: { a11y: {
element: 'nextjs-portal', element: 'nextjs-portal',
config: {
standards: {
ariaAttrs: {
'aria-modal': {
global: true,
},
},
},
rules: [
{
// It's incredibly hard to find a code highlighting theme that works
// for both light and dark themes and passes WCAG color contrast.
// These kind of tests should really only fail when you regress
// on a value below threshold.
id: 'color-contrast',
selector: '.code-frame-lines',
enabled: false,
},
],
},
}, },
controls: { controls: {
matchers: { matchers: {
......
...@@ -9,6 +9,18 @@ const meta: Meta<typeof CallStackFrame> = { ...@@ -9,6 +9,18 @@ const meta: Meta<typeof CallStackFrame> = {
backgrounds: { backgrounds: {
default: 'background-100-dark', default: 'background-100-dark',
}, },
a11y: {
config: {
rules: [
{
id: 'color-contrast',
// Manual testing shows no violation.
// TODO: We might have setup more explicit backgrounds depending on theme.
enabled: false,
},
],
},
},
}, },
decorators: [withShadowPortal], decorators: [withShadowPortal],
} }
......
...@@ -23,10 +23,6 @@ export const CallStackFrame: React.FC<{ ...@@ -23,10 +23,6 @@ export const CallStackFrame: React.FC<{
: undefined : undefined
) )
// Format method to strip out the webpack layer prefix.
// e.g. (app-pages-browser)/./app/page.tsx -> ./app/page.tsx
const formattedMethod = f.methodName.replace(/^\([\w-]+\)\//, '')
// Formatted file source could be empty. e.g. <anonymous> will be formatted to empty string, // Formatted file source could be empty. e.g. <anonymous> will be formatted to empty string,
// we'll skip rendering the frame in this case. // we'll skip rendering the frame in this case.
const fileSource = getFrameSource(f) const fileSource = getFrameSource(f)
...@@ -42,9 +38,13 @@ export const CallStackFrame: React.FC<{ ...@@ -42,9 +38,13 @@ export const CallStackFrame: React.FC<{
data-nextjs-call-stack-frame-ignored={frame.ignored} data-nextjs-call-stack-frame-ignored={frame.ignored}
> >
<div className="call-stack-frame-method-name"> <div className="call-stack-frame-method-name">
<HotlinkedText text={formattedMethod} /> <HotlinkedText text={f.methodName} />
{hasSource && ( {hasSource && (
<button onClick={open} className="open-in-editor-button"> <button
onClick={open}
className="open-in-editor-button"
aria-label={`Open ${f.methodName} in editor`}
>
<ExternalIcon width={16} height={16} /> <ExternalIcon width={16} height={16} />
</button> </button>
)} )}
......
...@@ -9,6 +9,18 @@ const meta: Meta<typeof CallStack> = { ...@@ -9,6 +9,18 @@ const meta: Meta<typeof CallStack> = {
backgrounds: { backgrounds: {
default: 'background-100-dark', default: 'background-100-dark',
}, },
a11y: {
config: {
rules: [
{
id: 'color-contrast',
// Manual testing shows no violation.
// TODO: We might have setup more explicit backgrounds depending on theme.
enabled: false,
},
],
},
},
}, },
decorators: [withShadowPortal], decorators: [withShadowPortal],
} }
......
...@@ -8,6 +8,7 @@ const meta: Meta<typeof NextLogo> = { ...@@ -8,6 +8,7 @@ const meta: Meta<typeof NextLogo> = {
layout: 'centered', layout: 'centered',
}, },
args: { args: {
'aria-label': 'Open Next.js DevTools',
onClick: () => console.log('Clicked!'), onClick: () => console.log('Clicked!'),
}, },
decorators: [withShadowPortal], decorators: [withShadowPortal],
......
...@@ -6,6 +6,21 @@ const meta: Meta<typeof ErrorMessage> = { ...@@ -6,6 +6,21 @@ const meta: Meta<typeof ErrorMessage> = {
component: ErrorMessage, component: ErrorMessage,
parameters: { parameters: {
layout: 'fullscreen', layout: 'fullscreen',
backgrounds: {
default: 'background-100-light',
},
a11y: {
config: {
rules: [
{
id: 'color-contrast',
// Manual testing shows no violation.
// TODO: We might have setup more explicit backgrounds depending on theme.
enabled: false,
},
],
},
},
}, },
decorators: [withShadowPortal], decorators: [withShadowPortal],
} }
......
...@@ -50,10 +50,9 @@ import { CollapseIcon } from '../../icons/collapse-icon' ...@@ -50,10 +50,9 @@ import { CollapseIcon } from '../../icons/collapse-icon'
*/ */
export function PseudoHtmlDiff({ export function PseudoHtmlDiff({
reactOutputComponentDiff, reactOutputComponentDiff,
...props
}: { }: {
reactOutputComponentDiff: string reactOutputComponentDiff: string
} & React.HTMLAttributes<HTMLPreElement>) { }) {
const [isDiffCollapsed, toggleCollapseHtml] = useState(true) const [isDiffCollapsed, toggleCollapseHtml] = useState(true)
const htmlComponents = useMemo(() => { const htmlComponents = useMemo(() => {
...@@ -120,12 +119,14 @@ export function PseudoHtmlDiff({ ...@@ -120,12 +119,14 @@ export function PseudoHtmlDiff({
data-nextjs-container-errors-pseudo-html-collapse={isDiffCollapsed} data-nextjs-container-errors-pseudo-html-collapse={isDiffCollapsed}
> >
<button <button
aria-expanded={!isDiffCollapsed}
aria-label="complete Component Stack"
data-nextjs-container-errors-pseudo-html-collapse-button data-nextjs-container-errors-pseudo-html-collapse-button
onClick={() => toggleCollapseHtml(!isDiffCollapsed)} onClick={() => toggleCollapseHtml(!isDiffCollapsed)}
> >
<CollapseIcon collapsed={isDiffCollapsed} /> <CollapseIcon collapsed={isDiffCollapsed} />
</button> </button>
<pre {...props}> <pre className="nextjs__container_errors__component-stack">
<code>{htmlComponents}</code> <code>{htmlComponents}</code>
</pre> </pre>
</div> </div>
......
...@@ -6,6 +6,18 @@ const meta: Meta<typeof Terminal> = { ...@@ -6,6 +6,18 @@ const meta: Meta<typeof Terminal> = {
component: Terminal, component: Terminal,
parameters: { parameters: {
layout: 'fullscreen', layout: 'fullscreen',
a11y: {
config: {
rules: [
{
id: 'color-contrast',
// Manual testing shows no violation.
// TODO: We might have setup more explicit backgrounds depending on theme.
enabled: false,
},
],
},
},
}, },
decorators: [withShadowPortal], decorators: [withShadowPortal],
} }
......
...@@ -202,7 +202,6 @@ export function Errors({ ...@@ -202,7 +202,6 @@ export function Errors({
{errorDetails.reactOutputComponentDiff ? ( {errorDetails.reactOutputComponentDiff ? (
<PseudoHtmlDiff <PseudoHtmlDiff
className="nextjs__container_errors__component-stack"
reactOutputComponentDiff={errorDetails.reactOutputComponentDiff || ''} reactOutputComponentDiff={errorDetails.reactOutputComponentDiff || ''}
/> />
) : null} ) : null}
......
...@@ -16,6 +16,18 @@ const meta: Meta<typeof DevOverlay> = { ...@@ -16,6 +16,18 @@ const meta: Meta<typeof DevOverlay> = {
component: DevOverlay, component: DevOverlay,
parameters: { parameters: {
layout: 'fullscreen', layout: 'fullscreen',
a11y: {
config: {
rules: [
{
id: 'color-contrast',
// Manual testing shows no violation.
// TODO: We might have setup more explicit backgrounds depending on theme.
enabled: false,
},
],
},
},
}, },
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment