diff --git a/packages/base-styles/_z-index.scss b/packages/base-styles/_z-index.scss
index af679edb910642..6f7e3f2f13c309 100644
--- a/packages/base-styles/_z-index.scss
+++ b/packages/base-styles/_z-index.scss
@@ -25,7 +25,6 @@ $z-layers: (
".components-popover__close": 5,
".block-editor-block-list__insertion-point": 6,
".block-editor-warning": 5,
- ".block-library-gallery-item__inline-menu": 20,
".block-editor-url-input__suggestions": 30,
".edit-post-layout__footer": 30,
".interface-interface-skeleton__header": 30,
diff --git a/packages/block-editor/src/components/inspector-controls-tabs/position-controls-panel.js b/packages/block-editor/src/components/inspector-controls-tabs/position-controls-panel.js
index 42a8597227dee9..17f65d58b8f74b 100644
--- a/packages/block-editor/src/components/inspector-controls-tabs/position-controls-panel.js
+++ b/packages/block-editor/src/components/inspector-controls-tabs/position-controls-panel.js
@@ -2,11 +2,11 @@
* WordPress dependencies
*/
import {
- PanelBody,
__experimentalUseSlotFills as useSlotFills,
+ __experimentalToolsPanel as ToolsPanel,
+ __experimentalToolsPanelItem as ToolsPanelItem,
} from '@wordpress/components';
-import { useSelect } from '@wordpress/data';
-import { useLayoutEffect, useState } from '@wordpress/element';
+import { useDispatch, useSelect } from '@wordpress/data';
import { __ } from '@wordpress/i18n';
/**
@@ -15,40 +15,75 @@ import { __ } from '@wordpress/i18n';
import InspectorControlsGroups from '../inspector-controls/groups';
import { default as InspectorControls } from '../inspector-controls';
import { store as blockEditorStore } from '../../store';
+import { useToolsPanelDropdownMenuProps } from '../global-styles/utils';
+import { cleanEmptyObject } from '../../hooks/utils';
const PositionControlsPanel = () => {
- const [ initialOpen, setInitialOpen ] = useState();
+ const { selectedClientIds, selectedBlocks, hasPositionAttribute } =
+ useSelect( ( select ) => {
+ const { getBlocksByClientId, getSelectedBlockClientIds } =
+ select( blockEditorStore );
- // Determine whether the panel should be expanded.
- const { multiSelectedBlocks } = useSelect( ( select ) => {
- const { getBlocksByClientId, getSelectedBlockClientIds } =
- select( blockEditorStore );
- const clientIds = getSelectedBlockClientIds();
- return {
- multiSelectedBlocks: getBlocksByClientId( clientIds ),
- };
- }, [] );
+ const selectedBlockClientIds = getSelectedBlockClientIds();
+ const _selectedBlocks = getBlocksByClientId(
+ selectedBlockClientIds
+ );
- useLayoutEffect( () => {
- // If any selected block has a position set, open the panel by default.
- // The first block's value will still be used within the control though.
- if ( initialOpen === undefined ) {
- setInitialOpen(
- multiSelectedBlocks.some(
+ return {
+ selectedClientIds: selectedBlockClientIds,
+ selectedBlocks: _selectedBlocks,
+ hasPositionAttribute: _selectedBlocks?.some(
( { attributes } ) => !! attributes?.style?.position?.type
- )
- );
+ ),
+ };
+ }, [] );
+
+ const { updateBlockAttributes } = useDispatch( blockEditorStore );
+ const dropdownMenuProps = useToolsPanelDropdownMenuProps();
+
+ function resetPosition() {
+ if ( ! selectedClientIds?.length || ! selectedBlocks?.length ) {
+ return;
}
- }, [ initialOpen, multiSelectedBlocks, setInitialOpen ] );
+
+ const attributesByClientId = Object.fromEntries(
+ selectedBlocks?.map( ( { clientId, attributes } ) => [
+ clientId,
+ {
+ style: cleanEmptyObject( {
+ ...attributes?.style,
+ position: {
+ ...attributes?.style?.position,
+ type: undefined,
+ top: undefined,
+ right: undefined,
+ bottom: undefined,
+ left: undefined,
+ },
+ } ),
+ },
+ ] )
+ );
+
+ updateBlockAttributes( selectedClientIds, attributesByClientId, true );
+ }
return (
-
-
-
+ hasPositionAttribute }
+ onDeselect={ resetPosition }
+ >
+
+
+
);
};
diff --git a/packages/block-library/src/gallery/editor.scss b/packages/block-library/src/gallery/editor.scss
index d204d0347d8eb4..62c0eff788746d 100644
--- a/packages/block-library/src/gallery/editor.scss
+++ b/packages/block-library/src/gallery/editor.scss
@@ -117,10 +117,6 @@
opacity: 0.3;
}
- .is-selected .block-library-gallery-item__inline-menu {
- display: inline-flex;
- }
-
.block-editor-media-placeholder {
margin: 0;
height: 100%;
@@ -131,58 +127,6 @@
}
}
-.block-library-gallery-item__inline-menu {
- display: none;
- position: absolute;
- top: -2px;
- margin: $grid-unit-10;
- z-index: z-index(".block-library-gallery-item__inline-menu");
- border-radius: $radius-small;
- background: $white;
- border: $border-width solid $gray-900;
-
- @media not (prefers-reduced-motion) {
- transition: box-shadow 0.2s ease-out;
- }
-
- &:hover {
- box-shadow: $elevation-x-small;
- }
-
- @include break-small() {
- // Use smaller buttons to fit when there are many columns.
- .columns-7 &,
- .columns-8 & {
- padding: $grid-unit-05 * 0.5;
- }
- }
-
- .components-button.has-icon {
- &:not(:focus) {
- border: none;
- box-shadow: none;
- }
-
- @include break-small() {
- // Use smaller buttons to fit when there are many columns.
- .columns-7 &,
- .columns-8 & {
- padding: 0;
- width: inherit;
- height: inherit;
- }
- }
- }
-
- &.is-left {
- left: -2px;
- }
-
- &.is-right {
- right: -2px;
- }
-}
-
.wp-block-gallery ul.blocks-gallery-grid {
padding: 0;
// Some themes give all
default margin instead of padding.
diff --git a/packages/block-library/src/latest-posts/constants.js b/packages/block-library/src/latest-posts/constants.js
index 70c34448a3bff6..bcb367ce9d7448 100644
--- a/packages/block-library/src/latest-posts/constants.js
+++ b/packages/block-library/src/latest-posts/constants.js
@@ -1,3 +1,4 @@
export const MIN_EXCERPT_LENGTH = 10;
export const MAX_EXCERPT_LENGTH = 100;
export const MAX_POSTS_COLUMNS = 6;
+export const DEFAULT_EXCERPT_LENGTH = 55;
diff --git a/packages/block-library/src/latest-posts/edit.js b/packages/block-library/src/latest-posts/edit.js
index 82f0661d04e40f..95c72ea538b0ef 100644
--- a/packages/block-library/src/latest-posts/edit.js
+++ b/packages/block-library/src/latest-posts/edit.js
@@ -17,6 +17,8 @@ import {
ToolbarGroup,
__experimentalToggleGroupControl as ToggleGroupControl,
__experimentalToggleGroupControlOptionIcon as ToggleGroupControlOptionIcon,
+ __experimentalToolsPanel as ToolsPanel,
+ __experimentalToolsPanelItem as ToolsPanelItem,
} from '@wordpress/components';
import { __, _x, sprintf } from '@wordpress/i18n';
import { dateI18n, format, getSettings } from '@wordpress/date';
@@ -49,7 +51,9 @@ import {
MIN_EXCERPT_LENGTH,
MAX_EXCERPT_LENGTH,
MAX_POSTS_COLUMNS,
+ DEFAULT_EXCERPT_LENGTH,
} from './constants';
+import { useToolsPanelDropdownMenuProps } from '../utils/hooks';
/**
* Module Constants
@@ -77,6 +81,8 @@ function getFeaturedImageDetails( post, size ) {
export default function LatestPostsEdit( { attributes, setAttributes } ) {
const instanceId = useInstanceId( LatestPostsEdit );
+ const dropdownMenuProps = useToolsPanelDropdownMenuProps();
+
const {
postsToShow,
order,
@@ -227,68 +233,137 @@ export default function LatestPostsEdit( { attributes, setAttributes } ) {
const hasPosts = !! latestPosts?.length;
const inspectorControls = (
-
-
+ setAttributes( {
+ displayPostContent: false,
+ displayPostContentRadio: 'excerpt',
+ excerptLength: DEFAULT_EXCERPT_LENGTH,
+ } )
+ }
+ dropdownMenuProps={ dropdownMenuProps }
+ >
+ !! displayPostContent }
label={ __( 'Post content' ) }
- checked={ displayPostContent }
- onChange={ ( value ) =>
- setAttributes( { displayPostContent: value } )
+ onDeselect={ () =>
+ setAttributes( { displayPostContent: false } )
}
- />
+ isShownByDefault
+ >
+
+ setAttributes( { displayPostContent: value } )
+ }
+ />
+
{ displayPostContent && (
- displayPostContentRadio !== 'excerpt' }
label={ __( 'Show' ) }
- selected={ displayPostContentRadio }
- options={ [
- { label: __( 'Excerpt' ), value: 'excerpt' },
- {
- label: __( 'Full post' ),
- value: 'full_post',
- },
- ] }
- onChange={ ( value ) =>
+ onDeselect={ () =>
setAttributes( {
- displayPostContentRadio: value,
+ displayPostContentRadio: 'excerpt',
} )
}
- />
+ isShownByDefault
+ >
+
+ setAttributes( {
+ displayPostContentRadio: value,
+ } )
+ }
+ />
+
) }
{ displayPostContent &&
displayPostContentRadio === 'excerpt' && (
-
+ excerptLength !== DEFAULT_EXCERPT_LENGTH
+ }
label={ __( 'Max number of words' ) }
- value={ excerptLength }
- onChange={ ( value ) =>
- setAttributes( { excerptLength: value } )
+ onDeselect={ () =>
+ setAttributes( {
+ excerptLength: DEFAULT_EXCERPT_LENGTH,
+ } )
}
- min={ MIN_EXCERPT_LENGTH }
- max={ MAX_EXCERPT_LENGTH }
- />
+ isShownByDefault
+ >
+
+ setAttributes( { excerptLength: value } )
+ }
+ min={ MIN_EXCERPT_LENGTH }
+ max={ MAX_EXCERPT_LENGTH }
+ />
+
) }
-
+
-
-
+ setAttributes( {
+ displayAuthor: false,
+ displayPostDate: false,
+ } )
+ }
+ dropdownMenuProps={ dropdownMenuProps }
+ >
+ !! displayAuthor }
label={ __( 'Display author name' ) }
- checked={ displayAuthor }
- onChange={ ( value ) =>
- setAttributes( { displayAuthor: value } )
+ onDeselect={ () =>
+ setAttributes( { displayAuthor: false } )
}
- />
-
+
+ setAttributes( { displayAuthor: value } )
+ }
+ />
+
+ !! displayPostDate }
label={ __( 'Display post date' ) }
- checked={ displayPostDate }
- onChange={ ( value ) =>
- setAttributes( { displayPostDate: value } )
+ onDeselect={ () =>
+ setAttributes( { displayPostDate: false } )
}
- />
-
-
+ isShownByDefault
+ >
+
+ setAttributes( { displayPostDate: value } )
+ }
+ />
+
+
event.preventDefault(),
- 'aria-disabled': true,
-};
-
export default function PostFeaturedImageEdit( {
clientId,
attributes,
@@ -318,11 +313,7 @@ export default function PostFeaturedImageEdit( {
{ controls }
{ !! isLink ? (
-
+
{ placeholder() }
) : (
@@ -430,11 +421,7 @@ export default function PostFeaturedImageEdit( {
{ /* If the featured image is linked, wrap in an tag to trigger any inherited link element styles */ }
{ !! isLink ? (
-
+
{ image }
) : (
diff --git a/packages/block-library/src/post-featured-image/editor.scss b/packages/block-library/src/post-featured-image/editor.scss
index 5fab62c571b1cf..3295fe14e62ac2 100644
--- a/packages/block-library/src/post-featured-image/editor.scss
+++ b/packages/block-library/src/post-featured-image/editor.scss
@@ -100,9 +100,9 @@
// When the Post Featured Image block is linked,
// it's wrapped with a disabled tag.
- // Restore cursor style so it doesn't appear 'clickable'.
+ // Ensure that the link is not clickable.
> a {
- cursor: default;
+ pointer-events: none;
}
// When the Post Featured Image block is linked,