Skip to content

Commit

Permalink
[Editor]: Select blocks in outline list
Browse files Browse the repository at this point in the history
  • Loading branch information
ntsekouras committed Feb 22, 2023
1 parent cf8335e commit a293977
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions packages/editor/src/components/document-outline/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*/
import { __ } from '@wordpress/i18n';
import { compose } from '@wordpress/compose';
import { withSelect } from '@wordpress/data';
import { withSelect, useDispatch } from '@wordpress/data';
import { create, getTextContent } from '@wordpress/rich-text';
import { store as blockEditorStore } from '@wordpress/block-editor';
import { store as coreStore } from '@wordpress/core-data';
Expand Down Expand Up @@ -68,7 +68,7 @@ export const DocumentOutline = ( {
hasOutlineItemsDisabled,
} ) => {
const headings = computeOutlineHeadings( blocks );

const { selectBlock } = useDispatch( blockEditorStore );
if ( headings.length < 1 ) {
return null;
}
Expand Down Expand Up @@ -121,7 +121,10 @@ export const DocumentOutline = ( {
isValid={ isValid }
isDisabled={ hasOutlineItemsDisabled }
href={ `#block-${ item.clientId }` }
onSelect={ onSelect }
onSelect={ () => {
selectBlock( item.clientId );
onSelect?.();
} }
>
{ item.isEmpty
? emptyHeadingContent
Expand Down

0 comments on commit a293977

Please sign in to comment.