Skip to content
Prev Previous commit
Next Next commit
Storybook: improve examples
  • Loading branch information
ciampo committed Aug 31, 2022
commit c1a49f6fce4d51ae0a74fc0448c9896740b24729
18 changes: 14 additions & 4 deletions packages/components/src/popover/stories/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* WordPress dependencies
*/
import { useState, useRef } from '@wordpress/element';
import { useState, useRef, useEffect } from '@wordpress/element';
import { __unstableIframe as Iframe } from '@wordpress/block-editor';

/**
Expand Down Expand Up @@ -107,18 +107,26 @@ export const Default = ( args ) => {
const toggleVisible = () => {
setIsVisible( ( state ) => ! state );
};
const buttonRef = useRef();
useEffect( () => {
buttonRef.current?.focus();
}, [] );

return (
<div
style={ {
minWidth: '600px',
minHeight: '600px',
width: '300vw',
height: '300vh',
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
} }
>
<Button variant="secondary" onClick={ toggleVisible }>
<Button
variant="secondary"
onClick={ toggleVisible }
ref={ buttonRef }
>
Toggle Popover
{ isVisible && <Popover { ...args } /> }
</Button>
Expand Down Expand Up @@ -246,6 +254,8 @@ export const WithSlotOutsideIframe = ( args ) => {
style={ {
width: '100%',
height: '400px',
border: '0',
outline: '1px solid purple',
} }
>
<div
Expand Down