From d7fd57bfe9ef450d375f65d037a3db628109fc38 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Dungler?= Date: Wed, 15 Apr 2020 19:23:48 +0200 Subject: [PATCH] fix: default a11y parameters --- addons/a11y/src/a11yRunner.ts | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/addons/a11y/src/a11yRunner.ts b/addons/a11y/src/a11yRunner.ts index 21c44261cdb..3feb1279b0e 100644 --- a/addons/a11y/src/a11yRunner.ts +++ b/addons/a11y/src/a11yRunner.ts @@ -28,13 +28,7 @@ const run = async (storyId: string) => { if (!active) { active = true; - const { - element = getElement(), - config, - options = { - restoreScroll: true, - }, - } = input; + const { element = getElement(), config, options } = input; axe.reset(); if (config) { axe.configure(config); @@ -50,10 +44,18 @@ const run = async (storyId: string) => { } }; +/** Returns story parameters or default ones. */ const getParams = (storyId: string): Setup => { // eslint-disable-next-line no-underscore-dangle const { parameters } = window.__STORYBOOK_STORY_STORE__._stories[storyId] || {}; - return parameters.a11y; + return ( + parameters.a11y || { + config: {}, + options: { + restoreScroll: true, + }, + } + ); }; channel.on(STORY_RENDERED, run);