diff --git a/packages/block-library/src/latest-posts/constants.js b/packages/block-library/src/latest-posts/constants.js index 70c34448a3bff6..7719648d81860b 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 = 10; diff --git a/packages/block-library/src/latest-posts/edit.js b/packages/block-library/src/latest-posts/edit.js index 3a334def3e52c1..e40e592d6f1c1d 100644 --- a/packages/block-library/src/latest-posts/edit.js +++ b/packages/block-library/src/latest-posts/edit.js @@ -51,6 +51,7 @@ import { MIN_EXCERPT_LENGTH, MAX_EXCERPT_LENGTH, MAX_POSTS_COLUMNS, + DEFAULT_EXCERPT_LENGTH, } from './constants'; import { useToolsPanelDropdownMenuProps } from '../utils/hooks'; @@ -80,7 +81,7 @@ function getFeaturedImageDetails( post, size ) { export default function LatestPostsEdit( { attributes, setAttributes } ) { const instanceId = useInstanceId( LatestPostsEdit ); - const dropdownMenuProps = useToolsPanelDropdownMenuProps(); // Moved inside the component + const dropdownMenuProps = useToolsPanelDropdownMenuProps(); const { postsToShow, @@ -237,8 +238,8 @@ export default function LatestPostsEdit( { attributes, setAttributes } ) { resetAll={ () => setAttributes( { displayPostContent: false, - displayPostContentRadio: 'excerpt', // Set default value for the radio button - excerptLength: MIN_EXCERPT_LENGTH, // Default length for the excerpt + displayPostContentRadio: 'excerpt', + excerptLength: DEFAULT_EXCERPT_LENGTH, } ) } dropdownMenuProps={ dropdownMenuProps } @@ -249,6 +250,7 @@ export default function LatestPostsEdit( { attributes, setAttributes } ) { onDeselect={ () => setAttributes( { displayPostContent: false } ) } + isShownByDefault > { displayPostContent && ( displayPostContentRadio !== undefined } + hasValue={ () => !! displayPostContentRadio } label={ __( 'Show' ) } onDeselect={ () => setAttributes( { displayPostContentRadio: 'excerpt', } ) } + isShownByDefault > setAttributes( { - excerptLength: MIN_EXCERPT_LENGTH, + excerptLength: DEFAULT_EXCERPT_LENGTH, } ) } + isShownByDefault > setAttributes( { displayAuthor: false } ) } + isShownByDefault > setAttributes( { displayPostDate: false } ) } + isShownByDefault >