-
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
Components: Add types to Draggable #29792
Conversation
Size Change: +2 B (0%) Total Size: 1.41 MB
ℹ️ View Unchanged
|
*/ | ||
function end( event ) { | ||
event.preventDefault(); | ||
cleanup.current(); | ||
|
||
if ( onDragOver ) { | ||
if ( onDragEnd ) { |
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.
That seems like an existing bug. Wondering how/what it does.. Looking at: https://github.com/WordPress/gutenberg/pull/26897/files
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'm also not sure about this one. Any suggestions on how to test its impact?
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.
Sorry, I should have mentioned this in the PR description, I totally glossed over that this was a fix.
Not sure how to measure its impact, but theoretically any onDragEnd
event that was supposed to be fired was not being fired due to the lack of an onDragOver
. That sounds pretty bad in the context of this component 😬
I did some digging and it doens't look like Draggable is even used in the Gutenberg codebase so there's no way to test it here 😕
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.
Maybe if we ping the author of the original code?
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.
@ellatrix As you did the original refactor to a function component, do you mind chiming in on this? Is there a good way to test the result of this bug fix?
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.
It is used:
<Draggable |
gutenberg/packages/block-editor/src/components/inserter-draggable-blocks/index.js
Line 17 in da8555d
<Draggable |
Drag and drop is hard to test, but manually by testing the block drag handle.
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.
Ah, I don't know how I missed those usages!
Luckily, this bug would never have affected those two usages. One does not use the onDrag*
events passed to Draggable
at all and the other passes both onDragOver
and onDragEnd
meaning that this bug wouldn't have affected it.
Block dragging continues to work as expected.
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.
That's good. No tests required imo.
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.
Looking good 👍 The null change also looks safe. Left a couple of questions.
*/ | ||
function end( event ) { | ||
event.preventDefault(); | ||
cleanup.current(); | ||
|
||
if ( onDragOver ) { | ||
if ( onDragEnd ) { |
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'm also not sure about this one. Any suggestions on how to test its impact?
b0248c2
to
7c327c2
Compare
7c327c2
to
2722dd5
Compare
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.
Looks good. Thanks!
Description
Adds types to the
Draggable
component. No runtime changes except to change the ref from defaulting toundefined
to default tonull
. This should have no real effect as the null checks were just checking for flasy-ness rather thanundefined
specifically.Part of #18838
How has this been tested?
Storybook (
npm run storybook:dev
) and the Draggable story continues to work as expected. Again, there are no runtime changes except the minor one I mention above so the main thing is that type checks pass 🙂Types of changes
Non-breaking change.
Checklist: