From 89b47b41bd5e4cb7d746917e03a5c0ee01725d98 Mon Sep 17 00:00:00 2001 From: George Mamadashvili Date: Tue, 19 Nov 2024 15:14:25 +0400 Subject: [PATCH] Editor: Correctly select post title support in 'DocumentOutline' (#67109) Co-authored-by: Mamaduka --- packages/editor/README.md | 3 +-- packages/editor/src/components/document-outline/check.js | 2 +- packages/editor/src/components/document-outline/index.js | 6 ++---- 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/packages/editor/README.md b/packages/editor/README.md index e0b53362089f1b..07405d0d51c3d2 100644 --- a/packages/editor/README.md +++ b/packages/editor/README.md @@ -279,8 +279,7 @@ Renders a document outline component. _Parameters_ - _props_ `Object`: Props. -- _props.onSelect_ `Function`: Function to be called when an outline item is selected. -- _props.isTitleSupported_ `boolean`: Indicates whether the title is supported. +- _props.onSelect_ `Function`: Function to be called when an outline item is selected - _props.hasOutlineItemsDisabled_ `boolean`: Indicates whether the outline items are disabled. _Returns_ diff --git a/packages/editor/src/components/document-outline/check.js b/packages/editor/src/components/document-outline/check.js index 7e396f45c82f1a..d0676aa9037ffe 100644 --- a/packages/editor/src/components/document-outline/check.js +++ b/packages/editor/src/components/document-outline/check.js @@ -19,7 +19,7 @@ export default function DocumentOutlineCheck( { children } ) { return getGlobalBlockCount( 'core/heading' ) > 0; } ); - if ( hasHeadings ) { + if ( ! hasHeadings ) { return null; } diff --git a/packages/editor/src/components/document-outline/index.js b/packages/editor/src/components/document-outline/index.js index 2ed53f771b67b7..ab5caa8cf0f8a4 100644 --- a/packages/editor/src/components/document-outline/index.js +++ b/packages/editor/src/components/document-outline/index.js @@ -102,19 +102,17 @@ const isEmptyHeading = ( heading ) => * Renders a document outline component. * * @param {Object} props Props. - * @param {Function} props.onSelect Function to be called when an outline item is selected. - * @param {boolean} props.isTitleSupported Indicates whether the title is supported. + * @param {Function} props.onSelect Function to be called when an outline item is selected * @param {boolean} props.hasOutlineItemsDisabled Indicates whether the outline items are disabled. * * @return {Component} The component to be rendered. */ export default function DocumentOutline( { onSelect, - isTitleSupported, hasOutlineItemsDisabled, } ) { const { selectBlock } = useDispatch( blockEditorStore ); - const { blocks, title } = useSelect( ( select ) => { + const { blocks, title, isTitleSupported } = useSelect( ( select ) => { const { getBlocks } = select( blockEditorStore ); const { getEditedPostAttribute } = select( editorStore ); const { getPostType } = select( coreStore );