Skip to content

Commit

Permalink
PageAttributesCheck: Return boolean value directly from the selector (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
Mamaduka authored Feb 23, 2023
1 parent 26e00a8 commit 6acbb4b
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions packages/editor/src/components/page-attributes/check.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,16 @@ import { store as coreStore } from '@wordpress/core-data';
import { store as editorStore } from '../../store';

export function PageAttributesCheck( { children } ) {
const postType = useSelect( ( select ) => {
const supportsPageAttributes = useSelect( ( select ) => {
const { getEditedPostAttribute } = select( editorStore );
const { getPostType } = select( coreStore );
const postType = getPostType( getEditedPostAttribute( 'type' ) );

return getPostType( getEditedPostAttribute( 'type' ) );
return !! postType?.supports?.[ 'page-attributes' ];
}, [] );

// Only render fields if post type supports page attributes or available templates exist.
if ( ! postType?.supports?.[ 'page-attributes' ] ) {
if ( ! supportsPageAttributes ) {
return null;
}

Expand Down

1 comment on commit 6acbb4b

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Flaky tests detected in 6acbb4b.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/4253863034
📝 Reported issues:

Please sign in to comment.