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

Block Insertion: Clear the insertion point when selecting a different block or clearing block selection #64048

Merged
merged 5 commits into from
Aug 12, 2024
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
use block insertion point index
scruffian committed Aug 9, 2024
commit 46e51ac683ae053391bd37b617c3da9f1143c1b3
21 changes: 11 additions & 10 deletions packages/editor/src/components/inserter-sidebar/index.js
Original file line number Diff line number Diff line change
@@ -22,15 +22,17 @@ const { PrivateInserterLibrary } = unlock( blockEditorPrivateApis );

export default function InserterSidebar() {
const {
blockInsertionPoint,
blockSectionRootClientId,
inserterSidebarToggleRef,
blockInsertionPoint,
insertionPoint,
showMostUsedBlocks,
sidebarIsOpened,
} = useSelect( ( select ) => {
const {
getInserterSidebarToggleRef,
getBlockInsertionPoint,
getInserterSidebarToggleRef,
getInsertionPoint,
isPublishSidebarOpened,
} = unlock( select( editorStore ) );
const { getBlockRootClientId, __unstableGetEditorMode, getSettings } =
@@ -47,8 +49,9 @@ export default function InserterSidebar() {
return getBlockRootClientId();
};
return {
inserterSidebarToggleRef: getInserterSidebarToggleRef(),
blockInsertionPoint: getBlockInsertionPoint(),
inserterSidebarToggleRef: getInserterSidebarToggleRef(),
insertionPoint: getInsertionPoint(),
showMostUsedBlocks: get( 'core', 'mostUsedBlocks' ),
blockSectionRootClientId: getBlockSectionRootClientId(),
sidebarIsOpened: !! (
@@ -87,13 +90,11 @@ export default function InserterSidebar() {
rootClientId={
blockSectionRootClientId ?? blockInsertionPoint.rootClientId
}
__experimentalInsertionIndex={
blockInsertionPoint.insertionIndex
}
onSelect={ blockInsertionPoint.onSelect }
__experimentalInitialTab={ blockInsertionPoint.tab }
__experimentalInitialCategory={ blockInsertionPoint.category }
__experimentalFilterValue={ blockInsertionPoint.filterValue }
__experimentalInsertionIndex={ blockInsertionPoint.index }
onSelect={ insertionPoint.onSelect }
__experimentalInitialTab={ insertionPoint.tab }
__experimentalInitialCategory={ insertionPoint.category }
__experimentalFilterValue={ insertionPoint.filterValue }
onPatternCategorySelection={
sidebarIsOpened
? () => disableComplementaryArea( 'core' )