-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Fix issue where block inserted in wrong place when selection is in nested block list, but root appender is used. #23668
Conversation
} = select( 'core/block-editor' ); | ||
const { getBlockVariations } = select( 'core/blocks' ); | ||
|
||
rootClientId = | ||
rootClientId || | ||
getBlockRootClientId( clientId || getBlockSelectionEnd() ) || |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The issue was that rootClientId
and clientId
are undefined
for the root appender, so this fallback to getBlockSelectionEnd
would result in blocks being inserted in the wrong place (and potentially the wrong inserter items displayed).
Size Change: +1.79 kB (0%) Total Size: 1.13 MB
ℹ️ View Unchanged
|
Would it be possible to add an e2e test? |
@ellatrix E2E tests now added. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍
…sted block list, but root appender is used. (#23668) * Remove use of getSelectionEnd to determine where blocks should be inserted * Add e2e tests
@talldan Looks like this PR broke the global inserter in the widgets screen. I'm not sure what's the best path forward to avoid both issues in both places. |
Fix here #24045 |
Description
Fixes #23263. This also seems to fix an issue where the trailing inserter is sometimes on the left and sometimes on the right.
When clicking the trailing root appender while selection is in an inner blocks list, the block will be inserted where selection is instead of at the root level.
I did some digging and it looks like the code was added in #22140 for the widgets screen, so this PR essentially reverted part of that. This change might break things there, but it's hard to tell what.
How has this been tested?
Screenshots
Types of changes
Bug fix (non-breaking change which fixes an issue)
Checklist: