-
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
Extract block draggable scroll behaviour into React hook #23444
Extract block draggable scroll behaviour into React hook #23444
Conversation
Size Change: +61 B (0%) Total Size: 1.13 MB
ℹ️ View Unchanged
|
const scrollParentY = useRef( null ); | ||
|
||
const scrollEditorInterval = useRef( null ); | ||
const blockElementId = `block-${ clientIds[ 0 ] }`; |
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 right now we have a better way to get the block node from the tree using the "BlockNodes" context which means we can probably avoid this argument entirely.
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.
Oh yep, I recall seeing that. I've changed the code to use that.
I noticed as well that the code in the hook is fairly agnostic to any kind of drag/drop event, so I went with making the hook accept a dragElement
and BlockDraggable
now grabs the block's element from BlockNodes
context to pass into the hook.
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 didn't see any issues when testing manually, but this change seems to be causing some issues with end-to-end tests.
I'll work on fixing it tomorrow.
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 like this refactoring, I also wonder whether we can remove the "key" and the changes to BlockPopover from the other PR too.
Can the same procedure be used here? Thanks for working on this, Dan! |
fd06641
to
5c79b43
Compare
Tests are now passing, apart from PHP tests which seem to have started failing overnight. I can't see any merged PRs that might have caused it, so it's most likely an environment issue. Using admin privileges to merge this as it contains no PHP changes. |
Description
As mentioned in https://github.com/WordPress/gutenberg/pull/23082/files#r444178859, the new scroll behavior when dragging can be pretty neatly encapsulated into a React hook.
This PR moves the code into a hook, pretty much verbatim, with a few minor bits of renaming and updating of comments to meet coding standards.
How has this been tested?
master
.Types of changes
Non-breaking code quality change
Checklist: