Skip to content

Commit

Permalink
[Block Library]: Fix editable post blocks in Query Loop with zero `…
Browse files Browse the repository at this point in the history
…queryId` (#37629)
  • Loading branch information
ntsekouras committed Dec 27, 2021
1 parent 1bdb0bc commit 760815a
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion packages/block-library/src/post-author/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ function PostAuthorEdit( {
attributes,
setAttributes,
} ) {
const isDescendentOfQueryLoop = !! queryId;
const isDescendentOfQueryLoop = Number.isFinite( queryId );
const { authorId, authorDetails, authors } = useSelect(
( select ) => {
const { getEditedEntityRecord, getUser, getUsers } = select(
Expand Down
2 changes: 1 addition & 1 deletion packages/block-library/src/post-content/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ function EditableContent( { layout, context = {} } ) {

function Content( props ) {
const { context: { queryId, postType, postId } = {} } = props;
const isDescendentOfQueryLoop = !! queryId;
const isDescendentOfQueryLoop = Number.isFinite( queryId );
const userCanEdit = useCanEditEntity( 'postType', postType, postId );
const isEditable = userCanEdit && ! isDescendentOfQueryLoop;

Expand Down
2 changes: 1 addition & 1 deletion packages/block-library/src/post-date/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export default function PostDateEdit( {
context: { postId, postType, queryId },
setAttributes,
} ) {
const isDescendentOfQueryLoop = !! queryId;
const isDescendentOfQueryLoop = Number.isFinite( queryId );
const [ siteFormat ] = useEntityProp( 'root', 'site', 'date_format' );
const [ date, setDate ] = useEntityProp(
'postType',
Expand Down
2 changes: 1 addition & 1 deletion packages/block-library/src/post-excerpt/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export default function PostExcerptEditor( {
isSelected,
context: { postId, postType, queryId },
} ) {
const isDescendentOfQueryLoop = !! queryId;
const isDescendentOfQueryLoop = Number.isFinite( queryId );
const userCanEdit = useCanEditEntity( 'postType', postType, postId );
const isEditable = userCanEdit && ! isDescendentOfQueryLoop;
const [
Expand Down
2 changes: 1 addition & 1 deletion packages/block-library/src/post-featured-image/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ function PostFeaturedImageDisplay( {
setAttributes,
context: { postId, postType, queryId },
} ) {
const isDescendentOfQueryLoop = !! queryId;
const isDescendentOfQueryLoop = Number.isFinite( queryId );
const { isLink, height, width, scale } = attributes;
const [ featuredImage, setFeaturedImage ] = useEntityProp(
'postType',
Expand Down
2 changes: 1 addition & 1 deletion packages/block-library/src/post-title/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export default function PostTitleEdit( {
context: { postType, postId, queryId },
} ) {
const TagName = 0 === level ? 'p' : 'h' + level;
const isDescendentOfQueryLoop = !! queryId;
const isDescendentOfQueryLoop = Number.isFinite( queryId );
const userCanEdit = useCanEditEntity( 'postType', postType, postId );
const [ rawTitle = '', setTitle, fullTitle ] = useEntityProp(
'postType',
Expand Down

0 comments on commit 760815a

Please sign in to comment.