@@ -8,6 +8,7 @@ import { __unstableMotion as motion } from '@wordpress/components';
88import { store as preferencesStore } from '@wordpress/preferences' ;
99import { useState } from '@wordpress/element' ;
1010import { PinnedItems } from '@wordpress/interface' ;
11+ import { store as coreStore } from '@wordpress/core-data' ;
1112
1213/**
1314 * Internal dependencies
@@ -21,7 +22,6 @@ import MoreMenu from '../more-menu';
2122import PostPreviewButton from '../post-preview-button' ;
2223import PostPublishButtonOrToggle from '../post-publish-button/post-publish-button-or-toggle' ;
2324import PostSavedState from '../post-saved-state' ;
24- import PostTypeSupportCheck from '../post-type-support-check' ;
2525import PostViewLink from '../post-view-link' ;
2626import PreviewDropdown from '../preview-dropdown' ;
2727import ZoomOutToggle from '../zoom-out-toggle' ;
@@ -70,8 +70,10 @@ function Header( {
7070 hasFixedToolbar,
7171 hasBlockSelection,
7272 hasSectionRootClientId,
73+ supportsBlockComments,
7374 } = useSelect ( ( select ) => {
7475 const { get : getPreference } = select ( preferencesStore ) ;
76+ const { getPostType } = select ( coreStore ) ;
7577 const {
7678 getEditorMode,
7779 getCurrentPostType,
@@ -81,14 +83,23 @@ function Header( {
8183 select ( blockEditorStore )
8284 ) ;
8385
86+ const currentPostType = getCurrentPostType ( ) ;
87+ const _postType = getPostType ( currentPostType ) ;
88+
8489 return {
85- postType : getCurrentPostType ( ) ,
90+ postType : currentPostType ,
8691 isTextEditor : getEditorMode ( ) === 'text' ,
8792 isPublishSidebarOpened : _isPublishSidebarOpened ( ) ,
8893 showIconLabels : getPreference ( 'core' , 'showIconLabels' ) ,
8994 hasFixedToolbar : getPreference ( 'core' , 'fixedToolbar' ) ,
9095 hasBlockSelection : ! ! getBlockSelectionStart ( ) ,
9196 hasSectionRootClientId : ! ! getSectionRootClientId ( ) ,
97+ supportsBlockComments :
98+ _postType ?. supports ?. editor &&
99+ Array . isArray ( _postType . supports . editor ) &&
100+ ! ! _postType . supports . editor . find (
101+ ( item ) => item ?. [ 'block-comments' ] === true
102+ ) ,
92103 } ;
93104 } , [ ] ) ;
94105
@@ -197,11 +208,9 @@ function Header( {
197208 />
198209 ) }
199210
200- { isBlockCommentExperimentEnabled ? (
201- < PostTypeSupportCheck supportKeys = "block-comments" >
202- < CollabSidebar />
203- </ PostTypeSupportCheck >
204- ) : undefined }
211+ { isBlockCommentExperimentEnabled && supportsBlockComments && (
212+ < CollabSidebar />
213+ ) }
205214
206215 { customSaveButton }
207216 < MoreMenu />
0 commit comments