Skip to content

Commit c5026c8

Browse files
authored
Merge pull request #31621 from storybookjs/disable-highlights-during-a11y-tests
Addon A11y: Briefly disable highlights while Axe is running
2 parents 25f8c83 + 1aebaf0 commit c5026c8

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

code/addons/a11y/src/a11yRunner.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ export const run = async (input: A11yParameters = DEFAULT_PARAMETERS, storyId: s
5656

5757
const context: ContextSpec = {
5858
include: document?.body,
59-
exclude: ['.sb-wrapper', '#storybook-docs'], // Internal Storybook elements that are always in the document
59+
exclude: ['.sb-wrapper', '#storybook-docs', '#storybook-highlights-root'], // Internal Storybook elements that are always in the document
6060
};
6161

6262
if (input.context) {
@@ -93,6 +93,11 @@ export const run = async (input: A11yParameters = DEFAULT_PARAMETERS, storyId: s
9393
axe.configure(configWithDefault);
9494

9595
return new Promise<AxeResults>((resolve, reject) => {
96+
const highlightsRoot = document?.getElementById('storybook-highlights-root');
97+
if (highlightsRoot) {
98+
highlightsRoot.style.display = 'none';
99+
}
100+
96101
const task = async () => {
97102
try {
98103
const result = await axe.run(context, options);
@@ -108,6 +113,10 @@ export const run = async (input: A11yParameters = DEFAULT_PARAMETERS, storyId: s
108113
if (!isRunning) {
109114
runNext();
110115
}
116+
117+
if (highlightsRoot) {
118+
highlightsRoot.style.display = '';
119+
}
111120
});
112121
};
113122

0 commit comments

Comments
 (0)