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
Also set the insertion point in the quick inserter
scruffian committed Aug 9, 2024

Verified

This commit was signed with the committer’s verified signature. The key has expired.
tvdeyen Thomas von Deyen
commit dea7012c78484de66f76a4c30560ac09424d251f
Original file line number Diff line number Diff line change
@@ -9,7 +9,7 @@ import clsx from 'clsx';
import { useState, useEffect } from '@wordpress/element';
import { __ } from '@wordpress/i18n';
import { Button, SearchControl } from '@wordpress/components';
import { useSelect } from '@wordpress/data';
import { useDispatch, useSelect } from '@wordpress/data';

/**
* Internal dependencies
@@ -82,6 +82,8 @@ export default function QuickInserter( {
}
}, [ setInserterIsOpened ] );

const { showInsertionPoint } = useDispatch( blockEditorStore );

// When clicking Browse All select the appropriate block so as
// the insertion point can work as expected.
const onBrowseAll = () => {
@@ -91,6 +93,7 @@ export default function QuickInserter( {
filterValue,
onSelect,
} );
showInsertionPoint( rootClientId, insertionIndex );
};

let maxBlockPatterns = 0;
1 change: 1 addition & 0 deletions packages/block-editor/src/store/reducer.js
Original file line number Diff line number Diff line change
@@ -1624,6 +1624,7 @@ export function insertionPoint( state = null, action ) {
}

case 'HIDE_INSERTION_POINT':
case 'CLEAR_SELECTED_BLOCK':
case 'SELECT_BLOCK':
return null;
}
9 changes: 6 additions & 3 deletions packages/editor/src/components/inserter-sidebar/index.js
Original file line number Diff line number Diff line change
@@ -30,13 +30,16 @@ export default function InserterSidebar() {
sidebarIsOpened,
} = useSelect( ( select ) => {
const {
getBlockInsertionPoint,
getInserterSidebarToggleRef,
getInsertionPoint,
isPublishSidebarOpened,
} = unlock( select( editorStore ) );
const { getBlockRootClientId, __unstableGetEditorMode, getSettings } =
select( blockEditorStore );
const {
getBlockInsertionPoint,
getBlockRootClientId,
__unstableGetEditorMode,
getSettings,
} = select( blockEditorStore );
const { get } = select( preferencesStore );
const { getActiveComplementaryArea } = select( interfaceStore );
const getBlockSectionRootClientId = () => {