Block Editor: Don't close inserter panel when inline quick inserter opens - #76241
Conversation
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the Unlinked AccountsThe following contributors have not linked their GitHub and WordPress.org accounts: @finlay-x. Contributors, please read how to link your accounts to ensure your work is properly credited in WordPress releases. If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
|
Thanks for working on this, @Mustafabharmal! Do you mind rebasing the branch onto the latest trunk? |
b187a7f to
3cc8414
Compare
|
Thanks, @Mustafabharmal! While this fixes the mentioned issue, it introduces an unwanted side effect. Clicking on the 'Browse all' button now does nothing, and it seems like the action is broken. Maybe we revisit what the expected behavior should be here. cc @jeryj, @t-hamano ScreenshotCleanShot.2026-04-09.at.15.34.50.mp4 |
|
Thanks for looking at this @Mustafabharmal! I believe closing the sidebar inserter when clicking an on-canvas inserter is an intentional design choice. To fix the bug in #72297, I think we should:
What is making the bug that's making the inbetween quick inserter unmount? |
My investigation yielded the following results:
When the quickinserter is opened, this effect closes the sidebar inserter:
I'm not sure what the best approach is yet, but checking diff --git a/packages/block-editor/src/components/inserter/hooks/use-insertion-point.js b/packages/block-editor/src/components/inserter/hooks/use-insertion-point.js
index a79949085b8..f28b8d9dee4 100644
--- a/packages/block-editor/src/components/inserter/hooks/use-insertion-point.js
+++ b/packages/block-editor/src/components/inserter/hooks/use-insertion-point.js
@@ -75,6 +75,7 @@ function useInsertionPoint( {
getSelectedBlock,
getClosestAllowedInsertionPoint,
isBlockInsertionPointVisible,
+ getBlockInsertionPoint,
} = unlock( useSelect( blockEditorStore ) );
const { destinationRootClientId, destinationIndex } = useSelect(
( select ) => {
@@ -226,12 +227,18 @@ function useInsertionPoint( {
);
}
} else {
- hideInsertionPoint();
+ // Don't hide the insertion point owned by the in-between inserter.
+ const insertionPoint = getBlockInsertionPoint();
+ console.log(insertionPoint);
+ if ( ! insertionPoint?.__unstableWithInserter ) {
+ hideInsertionPoint();
+ }
}
},
[
getClosestAllowedInsertionPoint,
isBlockInsertionPointVisible,
+ getBlockInsertionPoint,
showInsertionPoint,
hideInsertionPoint,
destinationRootClientId, |
|
Thanks for the review, everyone. I’ve updated the implementation based on the feedback. |
|
As far as I can see, the code looks good. @Mustafabharmal, can you also add an e2e test? Perhaps the most suitable file would be |
|
@Mustafabharmal, I see you went in a different direction using ref for bookkeeping instead of The general problem with using refs to track values is that they can become stale, whereas selectors have the latest data. |
Yes @Mamaduka , there were a couple of reasons behind the initial shift to the ref-based approach. The main reason was to keep track of whether the insertion point was opened by the block inserter itself, rather than relying only on the current insertion cue. There are also some cues, such as drop-zone cues using However, after revisiting the implementation based on your feedback, I agree that the ref can become stale. In particular, Using Thanks for pointing this out, I think the selector-based approach is safer here. |
|
I found a small bug. Please try the following steps:
in-between.mp4As far as I tested, the following changes fixed the issue, but we need to perform smoke tests to ensure no other problems arise. diff --git a/packages/block-editor/src/components/inserter/hooks/use-insertion-point.js b/packages/block-editor
/src/components/inserter/hooks/use-insertion-point.js
index b78f268f702..a1a66b4c05c 100644
--- a/packages/block-editor/src/components/inserter/hooks/use-insertion-point.js
+++ b/packages/block-editor/src/components/inserter/hooks/use-insertion-point.js
@@ -67,7 +67,6 @@ function useInsertionPoint( {
const {
getSelectedBlock,
getClosestAllowedInsertionPoint,
- isBlockInsertionPointVisible,
getBlockInsertionPoint,
} = unlock( useSelect( blockEditorStore ) );
const { destinationRootClientId, destinationIndex } = useSelect(
@@ -202,7 +201,7 @@ function useInsertionPoint( {
const onToggleInsertionPoint = useCallback(
( item ) => {
- if ( item && ! isBlockInsertionPointVisible() ) {
+ if ( item ) {
const allowedDestinationRootClientId =
getClosestAllowedInsertionPoint(
item.name,
@@ -230,7 +229,6 @@ function useInsertionPoint( {
},
[
getClosestAllowedInsertionPoint,
- isBlockInsertionPointVisible,
getBlockInsertionPoint,
showInsertionPoint,
hideInsertionPoint, |
|
Looks good; just need changelog conflict resolution. |
What?
Closes #72297.
When the block inserter panel (sidebar) is open and a user clicks the inline block appender (in-between inserter), the panel was being force-closed.
Why?
QuickInserterhad auseEffectthat calledsetInserterIsOpened(false)on every mount:This unconditionally closed the inserter sidebar panel any time the inline quick inserter opened, even when the user had intentionally opened the panel beforehand.
How?
Remove the
useEffect. The inline quick inserter and the sidebar panel can coexist without conflict. The existing "Browse All" button already handles opening the sidebar panel with the correct insertion context when the user explicitly wants to expand to it.Testing Instructions
Screenshots or screencast
Before:
Before.Inserter.Fix.mov
After:
After.Inserter.Fix.mov