diff --git a/packages/edit-site/src/components/sidebar-navigation-screen-global-styles/index.js b/packages/edit-site/src/components/sidebar-navigation-screen-global-styles/index.js index 87a78952303a9..6baf073cd988e 100644 --- a/packages/edit-site/src/components/sidebar-navigation-screen-global-styles/index.js +++ b/packages/edit-site/src/components/sidebar-navigation-screen-global-styles/index.js @@ -51,20 +51,6 @@ export function SidebarNavigationItemGlobalStyles( props ) { ); } -function GlobalStylesStyleBook( { onClick, onSelect } ) { - return ( - false } - onClick={ onClick } - onSelect={ async ( blockName ) => { - await onSelect( blockName ); - } } - showCloseButton={ false } - showTabs={ false } - /> - ); -} - export default function SidebarNavigationScreenGlobalStyles() { const { openGeneralSidebar } = useDispatch( editSiteStore ); const isMobileViewport = useViewportMatch( 'medium', '<' ); @@ -87,11 +73,7 @@ export default function SidebarNavigationScreenGlobalStyles() { openGeneralSidebar( 'edit-site/global-styles' ), ] ); - const openStyleBook = async ( event ) => { - if ( event.defaultPrevented ) { - return; - } - event.preventDefault(); + const openStyleBook = async () => { await openGlobalStyles(); // Open the Style Book once the canvas mode is set to edit, // and the global styles sidebar is open. This ensures that @@ -136,9 +118,13 @@ export default function SidebarNavigationScreenGlobalStyles() { } /> { isStyleBookOpened && ! isMobileViewport && ( - false } onClick={ openStyleBook } onSelect={ openStyleBook } + showCloseButton={ false } + showTabs={ false } /> ) } diff --git a/packages/edit-site/src/components/style-book/index.js b/packages/edit-site/src/components/style-book/index.js index 379f1eb112cfa..c86d6df65045a 100644 --- a/packages/edit-site/src/components/style-book/index.js +++ b/packages/edit-site/src/components/style-book/index.js @@ -164,6 +164,7 @@ function getExamples() { } function StyleBook( { + enableResizing = true, isSelected, onClick, onSelect, @@ -201,7 +202,7 @@ function StyleBook( { return ( { const [ isFocused, setIsFocused ] = useState( false ); - // The presence of an `onClick` prop indicates that the Style Book is being used - // as a button. In this case, we need to add additional props to the iframe to - // make it behave like a button. + // The presence of an `onClick` prop indicates that the Style Book is being used as a button. + // In this case, add additional props to the iframe to make it behave like a button. const buttonModeProps = { role: 'button', onFocus: () => setIsFocused( true ), onBlur: () => setIsFocused( false ), onKeyDown: ( event ) => { + if ( event.defaultPrevented ) { + return; + } const { keyCode } = event; if ( onClick && ( keyCode === ENTER || keyCode === SPACE ) ) { + event.preventDefault(); onClick( event ); } }, onClick: ( event ) => { + if ( event.defaultPrevented ) { + return; + } if ( onClick ) { + event.preventDefault(); onClick( event ); } },