-
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
Refactor block drop event handlers into a single hook to support drag and drop in List View #24649
Refactor block drop event handlers into a single hook to support drag and drop in List View #24649
Conversation
Size Change: +525 B (0%) Total Size: 1.16 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.
Tested with blocks and files and it works well in the editor; not sure how to test an HTML drop though.
); | ||
} ); | ||
|
||
it( 'adjusts the index blocks are dropped at when moved down under the same root block', () => { |
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.
Hmm, is this too much of an implementation detail to be worth testing?
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.
e2e tests would definitely be better here, but there aren't any at the moment and they'd take a bit of investment.
This particular code has been buggy before (#24183), so a test seems beneficial.
} ); | ||
|
||
it( 'does nothing if the block has no matching file transforms', () => { | ||
findTransform.mockImplementation( () => {} ); |
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.
Why do we need to mock findTransform
again here? And could we use noop
defined at the top of the file?
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.
Hmm, I suppose not strictly required since jest.fn()
also returns nothing, though I feel like having this line helps demonstrate that it's performing the inverse of the following test.
I switched it over to use noop
and also added some comments.
@tellthemachines The easiest test I've found is to drag a link from another website. I'll update the testing instructions. |
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.
Re-tested, HTML drop is working fine!
Description
Separated from #23952.
Moves the code for handling block drop events into a separate react hook. This is required for #23952, as it'll allow List View to use the same drop event logic.
How has this been tested?
Types of changes
Non-breaking refactor.
Checklist: