Skip to content

Commit

Permalink
placeholders and bypass queryloop errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Addison-Stavlo authored and noahtallen committed Jul 20, 2020
1 parent 461f759 commit bea53c7
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 11 deletions.
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 @@ -9,7 +9,7 @@ import { __ } from '@wordpress/i18n';
import PostContentInnerBlocks from './inner-blocks';

export default function PostContentEdit( { context: { postId, postType } } ) {
if ( postId && postType ) {
if ( postId && postType && postType !== 'wp_template' ) {
return (
<PostContentInnerBlocks postType={ postType } postId={ postId } />
);
Expand Down
23 changes: 18 additions & 5 deletions packages/block-library/src/post-title/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,7 @@ import { __ } from '@wordpress/i18n';
*/
import HeadingLevelDropdown from '../heading/heading-level-dropdown';

export default function PostTitleEdit( {
attributes,
setAttributes,
context,
} ) {
function PostTitleEditor( { attributes, setAttributes, context } ) {
const { level, align } = attributes;
const { postType, postId } = context;
const tagName = 0 === level ? 'p' : 'h' + level;
Expand Down Expand Up @@ -72,3 +68,20 @@ export default function PostTitleEdit( {
</>
);
}

export default function PostTitleEdit( {
attributes,
setAttributes,
context,
} ) {
if ( ! context.postType || context.postType === 'wp_template' ) {
return <p>{ __( 'This is a placeholder for post title.' ) }</p>;
}
return (
<PostTitleEditor
attributes={ attributes }
setAttributes={ setAttributes }
context={ context }
/>
);
}
10 changes: 5 additions & 5 deletions packages/block-library/src/query-loop/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ import { useQueryContext } from '../query';
const TEMPLATE = [ [ 'core/post-title' ], [ 'core/post-content' ] ];
export default function QueryLoopEdit( {
clientId,
context: {
query: { perPage, offset, categoryIds },
queryContext,
},
context: { query: _query, queryContext },
} ) {
const [ { page } ] = useQueryContext() || queryContext;
const perPage = _query?.perPage;
const offset = _query?.offset;
const categoryIds = _query?.categoryIds;
const [ { page } ] = useQueryContext() || queryContext || [ {} ];
const [ activeBlockContext, setActiveBlockContext ] = useState();

const { posts, blocks } = useSelect(
Expand Down

0 comments on commit bea53c7

Please sign in to comment.