Skip to content

Commit

Permalink
Enhance Block Tools: Add inserter opened state to selector and update…
Browse files Browse the repository at this point in the history
… rendering logic
  • Loading branch information
yogeshbhutkar committed Dec 5, 2024
1 parent 600218e commit a605b82
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
13 changes: 10 additions & 3 deletions packages/block-editor/src/components/block-tools/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ function selector( select ) {
isTyping: isTyping(),
isZoomOutMode: isZoomOut(),
isDragging: isDragging(),
isInserterOpened: getSettings().__experimentalIsInserterOpened,
};
}

Expand All @@ -61,8 +62,14 @@ export default function BlockTools( {
__unstableContentRef,
...props
} ) {
const { clientId, hasFixedToolbar, isTyping, isZoomOutMode, isDragging } =
useSelect( selector, [] );
const {
clientId,
hasFixedToolbar,
isTyping,
isZoomOutMode,
isDragging,
isInserterOpened,
} = useSelect( selector, [] );

const isMatch = useShortcutEventMatch();
const {
Expand Down Expand Up @@ -234,7 +241,7 @@ export default function BlockTools( {
name="__unstable-block-tools-after"
ref={ blockToolbarAfterRef }
/>
{ isZoomOutMode && ! isDragging && (
{ isZoomOutMode && ! isDragging && ! isInserterOpened && (
<ZoomOutModeInserters
__unstableContentRef={ __unstableContentRef }
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,11 @@ function useBlockEditorSettings( settings, postType, postId, renderingMode ) {

const forceDisableFocusMode = settings.focusMode === false;

const isInserterOpened = useSelect(
( select ) => select( editorStore ).isInserterOpened(),
[]
);

return useMemo( () => {
const blockEditorSettings = {
...Object.fromEntries(
Expand Down Expand Up @@ -326,6 +331,7 @@ function useBlockEditorSettings( settings, postType, postId, renderingMode ) {
postType === 'wp_navigation'
? [ [ 'core/navigation', {}, [] ] ]
: settings.template,
__experimentalIsInserterOpened: isInserterOpened,
__experimentalSetIsInserterOpened: setIsInserterOpened,
[ sectionRootClientIdKey ]: sectionRootClientId,
editorTool:
Expand Down Expand Up @@ -360,6 +366,7 @@ function useBlockEditorSettings( settings, postType, postId, renderingMode ) {
globalStylesData,
globalStylesLinksData,
renderingMode,
isInserterOpened,
] );
}

Expand Down

0 comments on commit a605b82

Please sign in to comment.