diff --git a/.storybook/focus-addon/register.tsx b/.storybook/focus-addon/register.tsx new file mode 100644 index 0000000..9284281 --- /dev/null +++ b/.storybook/focus-addon/register.tsx @@ -0,0 +1,11 @@ +import {addons, } from '@storybook/addons'; + +addons.register('initialFocus', () => { + addons.getChannel().on('currentStoryWasSet', () => focusIframe()); +}) + +const focusIframe = () => { + const previewIframe: HTMLInputElement | null = document.querySelector('#storybook-preview-iframe'); + + previewIframe?.focus?.(); + }