Skip to content

Commit

Permalink
fix: Navigate group blocks
Browse files Browse the repository at this point in the history
Previously, the block appender--i.e., the inline block inseter--was
forcibly hidden. This caused group blocks--Group, Columns, Row, etc--to
collapse visually, leaving the near-impossible to select or modify.
Reintroducing the block appender allows traversing and modifying group
blocks.
  • Loading branch information
dcalhoun committed Jan 30, 2025
1 parent c2bca3a commit 9f6b8c0
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 14 deletions.
12 changes: 12 additions & 0 deletions patches/@wordpress+block-editor+14.11.0.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
diff --git a/node_modules/@wordpress/block-editor/build-module/components/inserter/index.js b/node_modules/@wordpress/block-editor/build-module/components/inserter/index.js
index aa2e9a5..f2d8481 100644
--- a/node_modules/@wordpress/block-editor/build-module/components/inserter/index.js
+++ b/node_modules/@wordpress/block-editor/build-module/components/inserter/index.js
@@ -192,6 +192,7 @@ class Inserter extends Component {
shift: true
},
onToggle: this.onToggle,
+ open: this.props.open,
expandOnMobile: true,
headerTitle: __('Add a block'),
renderToggle: this.renderToggle,
4 changes: 4 additions & 0 deletions patches/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ Existing patches should be described and justified here.

## Patches

### `@wordpress/block-editor`

Expose an `open` prop on the `Inserter` component, allowing toggling the inserter visibility via the quick inserter's "Browse all" button.

### `@wordpress/editor`

Revert https://github.com/WordPress/gutenberg/pull/64892 and export the private `useBlockEditorSettings` API as it is required for GutenbergKit's use of the block editor settings. This can be removed once GutenbergKit resides in the Gutenberg repository, where we can access all the necessary APIs—both public and private.
14 changes: 12 additions & 2 deletions src/components/editor-toolbar/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
Inserter,
store as blockEditorStore,
} from '@wordpress/block-editor';
import { useSelect } from '@wordpress/data';
import { useSelect, useDispatch } from '@wordpress/data';
import {
Button,
Popover,
Expand All @@ -19,6 +19,7 @@ import {
import { __ } from '@wordpress/i18n';
import { close, cog } from '@wordpress/icons';
import clsx from 'clsx';
import { store as editorStore } from '@wordpress/editor';

/**
* Internal dependencies
Expand All @@ -41,6 +42,12 @@ const EditorToolbar = ({ className }) => {
isSelected: selectedBlockClientId !== null,
};
});
const { isInserterOpened } = useSelect((select) => {
return {
isInserterOpened: select(editorStore).isInserterOpened(),
};
}, []);
const { setIsInserterOpened } = useDispatch(editorStore);

function openSettings() {
setBlockInspectorShown(true);
Expand All @@ -60,7 +67,10 @@ const EditorToolbar = ({ className }) => {
variant="unstyled"
>
<ToolbarGroup>
<Inserter />
<Inserter
open={isInserterOpened}
onToggle={setIsInserterOpened}
/>
</ToolbarGroup>

{isSelected && (
Expand Down
13 changes: 1 addition & 12 deletions src/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,7 @@
width: 320px;
}

/* The two selectors below hide the inline inserters shown inside the block list */
.block-editor-block-list__layout .block-editor-inserter {
display: none;
}

// Hide the inline insterter shown inside the block list
.block-editor-block-list__block-side-inserter-popover {
display: none;
}
Expand Down Expand Up @@ -115,13 +111,6 @@
padding-right: 8px !important;
}

// Inserter section header
.block-editor-inserter__panel-header {
display: block;
border-bottom: 1px solid lightgray;
padding-bottom: 12px;
}

// Inserter title
.components-popover__header-title {
font-size: 17px;
Expand Down

0 comments on commit 9f6b8c0

Please sign in to comment.