Skip to content

Commit

Permalink
Feedback changes
Browse files Browse the repository at this point in the history
  • Loading branch information
karthick-murugan committed Jan 21, 2025
1 parent ec1d6a4 commit ca67193
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
1 change: 1 addition & 0 deletions packages/block-library/src/latest-posts/constants.js
Original file line number Diff line number Diff line change
@@ -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;
16 changes: 11 additions & 5 deletions packages/block-library/src/latest-posts/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ import {
MIN_EXCERPT_LENGTH,
MAX_EXCERPT_LENGTH,
MAX_POSTS_COLUMNS,
DEFAULT_EXCERPT_LENGTH,
} from './constants';
import { useToolsPanelDropdownMenuProps } from '../utils/hooks';

Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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 }
Expand All @@ -249,6 +250,7 @@ export default function LatestPostsEdit( { attributes, setAttributes } ) {
onDeselect={ () =>
setAttributes( { displayPostContent: false } )
}
isShownByDefault
>
<ToggleControl
__nextHasNoMarginBottom
Expand All @@ -261,13 +263,14 @@ export default function LatestPostsEdit( { attributes, setAttributes } ) {
</ToolsPanelItem>
{ displayPostContent && (
<ToolsPanelItem
hasValue={ () => displayPostContentRadio !== undefined }
hasValue={ () => !! displayPostContentRadio }
label={ __( 'Show' ) }
onDeselect={ () =>
setAttributes( {
displayPostContentRadio: 'excerpt',
} )
}
isShownByDefault
>
<RadioControl
label={ __( 'Show' ) }
Expand All @@ -294,9 +297,10 @@ export default function LatestPostsEdit( { attributes, setAttributes } ) {
label={ __( 'Max number of words' ) }
onDeselect={ () =>
setAttributes( {
excerptLength: MIN_EXCERPT_LENGTH,
excerptLength: DEFAULT_EXCERPT_LENGTH,
} )
}
isShownByDefault
>
<RangeControl
__nextHasNoMarginBottom
Expand Down Expand Up @@ -329,6 +333,7 @@ export default function LatestPostsEdit( { attributes, setAttributes } ) {
onDeselect={ () =>
setAttributes( { displayAuthor: false } )
}
isShownByDefault
>
<ToggleControl
__nextHasNoMarginBottom
Expand All @@ -345,6 +350,7 @@ export default function LatestPostsEdit( { attributes, setAttributes } ) {
onDeselect={ () =>
setAttributes( { displayPostDate: false } )
}
isShownByDefault
>
<ToggleControl
__nextHasNoMarginBottom
Expand Down

0 comments on commit ca67193

Please sign in to comment.