Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Block Library]: Fix editable post blocks in Query Loop with zero queryId #37629

Merged
merged 1 commit into from
Dec 27, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
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
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