Skip to content

Commit

Permalink
fix(storybook): add focus on story iframe
Browse files Browse the repository at this point in the history
  • Loading branch information
Lunory committed Sep 29, 2023
1 parent 3352042 commit e83e8ce
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions .storybook/focus-addon/register.tsx
Original file line number Diff line number Diff line change
@@ -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?.();
}

0 comments on commit e83e8ce

Please sign in to comment.