-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Zoom Out: Use the block editor for insertion point data #63934
Zoom Out: Use the block editor for insertion point data #63934
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 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. |
Size Change: +22 B (0%) Total Size: 1.76 MB
ℹ️ View Unchanged
|
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.
Works as expected and the code looks good, thanks for fixing this!
@@ -86,6 +79,8 @@ function ZoomOutModeInserters() { | |||
hoveredBlockClientId === previousClientId || | |||
hoveredBlockClientId === nextClientId; | |||
|
|||
const { showInsertionPoint } = unlock( blockEditorDispatch ); |
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.
I think we can unlock the action once instead of doing it in a loop.
This should also work:
const { showInsertionPoint } = unlock( useDispatch( blockEditorStore ) );
Edit: The showInsertionPoint
looks to be a public action. Why are we unlocking it?
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.
When I did it earlier in the component I got this error from the linter:
Variables should not be assigned until just prior its first reference. An early return statement may leave this variable unused
And when it's later I get:
React Hook "useDispatch" is called conditionally. React Hooks must be called in the exact same order in every component render. Did you accidentally call a React Hook after an early return?
That's why I split it in two!
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.
I think it only triggers that error when using unlock
. It doesn't do it without it. Probably worth investigating separately.
Now that unlocking isn't needed, you can safely do const { showInsertionPoint } = useDispatch( blockEditorStore );
earlier in the component.
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.
@scruffian, it looks like you already merged PR, so here's the quick follow-up - #63936
I'm also curious if you tested this with page content focus - #63934 (comment).
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.
Btw, the |
What?
We should be using the insertion point information from the block editor store, not the editor store.
Why?
I'm not sure why it was done this way, but getting it from the block editor store means that we can respond to drag and drop events which will help with #63896.
How?
Replace
insertionPoint
from the editor store withgetBlockInsertionPoint
from the block editor store.Testing Instructions
Screenshot