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

Editor: Correctly select post title support in 'DocumentOutline' #67109

Merged
merged 1 commit into from
Nov 19, 2024
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
3 changes: 1 addition & 2 deletions packages/editor/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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_
Expand Down
2 changes: 1 addition & 1 deletion packages/editor/src/components/document-outline/check.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export default function DocumentOutlineCheck( { children } ) {
return getGlobalBlockCount( 'core/heading' ) > 0;
} );

if ( hasHeadings ) {
if ( ! hasHeadings ) {
Copy link
Member Author

Choose a reason for hiding this comment

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

I thought I'd fixed it, but changes probably got lost during the force push.

Props to @t-hamano for pointing it out initially.

return null;
}

Expand Down
6 changes: 2 additions & 4 deletions packages/editor/src/components/document-outline/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down
Loading