Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion packages/edit-widgets/src/blocks/widget-area/edit/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
/**
* External dependencies
*/
import classnames from 'classnames';

/**
* WordPress dependencies
*/
Expand All @@ -9,6 +14,7 @@ import {
Panel,
PanelBody,
} from '@wordpress/components';
import { cleanForSlug } from '@wordpress/url';

/**
* Internal dependencies
Expand All @@ -24,6 +30,11 @@ export default function WidgetAreaEdit( {
className,
attributes: { id, name },
} ) {
const areaClassName = classnames(
className,
'widget-area',
cleanForSlug( name )
);
const isOpen = useSelect(
( select ) =>
select( editWidgetsStore ).getIsWidgetAreaOpen( clientId ),
Expand Down Expand Up @@ -55,7 +66,7 @@ export default function WidgetAreaEdit( {
}, [ isOpen, isDragging, isDraggingWithin, openedWhileDragging ] );

return (
<Panel className={ className } ref={ wrapper }>
<Panel className={ areaClassName } ref={ wrapper }>
<PanelBody
title={ name }
opened={ isOpen }
Expand Down
1 change: 1 addition & 0 deletions packages/widgets/src/blocks/legacy-widget/edit/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ function NotEmpty( {
idBase={ idBase }
instance={ instance }
isVisible={ mode === 'preview' }
name={ widgetType.name }
/>
) }
{ hasPreview === false && mode === 'preview' && (
Expand Down
5 changes: 3 additions & 2 deletions packages/widgets/src/blocks/legacy-widget/edit/preview.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ import classnames from 'classnames';
* WordPress dependencies
*/
import { useRefEffect } from '@wordpress/compose';
import { addQueryArgs } from '@wordpress/url';
import { addQueryArgs, cleanForSlug } from '@wordpress/url';
import { useState } from '@wordpress/element';
import { Placeholder, Spinner, Disabled } from '@wordpress/components';
import { __ } from '@wordpress/i18n';

export default function Preview( { idBase, instance, isVisible } ) {
export default function Preview( { idBase, instance, isVisible, name } ) {
const [ isLoaded, setIsLoaded ] = useState( false );

// Resize the iframe on either the load event, or when the iframe becomes visible.
Expand Down Expand Up @@ -78,6 +78,7 @@ export default function Preview( { idBase, instance, isVisible } ) {
) }
<div
className={ classnames(
cleanForSlug( 'widget_' + name ),
'wp-block-legacy-widget__edit-preview',
{
'is-offscreen': ! isVisible || ! isLoaded,
Expand Down