-
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
BlockListAppender: with custom appender, don't react to nested list settings changes #46461
Conversation
Size Change: +11 B (0%) Total Size: 1.32 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.
The code is looking great, nice find Jarda!
Some testing instructions would be nice. I'm happy to defer testing to the more familiar eyes also.
This is hard because you'd have to build the mobile app from this branch and test it. Create a "Columns" block with two columns, and then select one column, and verify that it has a working block inserter (the + icon) in the bottom toolbar: On the other hand this is exactly what the unit tests are testing, so you might want to trust them and give up manual 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.
This looks great, and tests well in web. Given tests pass, I don't see why it wouldn't work well in RN. I'd be happy to ship it 👍
I'll have to devote half a day to set up my mobile build again, but for now I'll pass on giving this a spin on mobile.
I'll leave it to you @jsnajdr as to whether to wait for an approval from mobile folks or ship immediately.
86baeaa
to
f113506
Compare
f113506
to
fa92a93
Compare
Unit tests written with React Testing Library don't like situations where:
Promise.then
handlerIn such a case the "update not wrapped in
act()
" warning is triggered -- something has changed asychronously and the test didn't catch it by waiting for the change to happen.This situation happens when testing the mobile columns block. You create a new column block, synchronously perform the test actions on it (like changing vertical alignment) and then finish the test. However, there is another process going on: the column block initially has no
blockListSettings
, andupdateBlockListSettings
dispatch for it gets async scheduled. This dispatch affects rendering of the block inserter (the + icon in the mobile toolbar):Because this inserter asks whether it can insert the default block (
canInsertDefaultBlock
). Initially this isfalse
because the column block doesn't yet have any list settings, and later becomestrue
. That leads to rerender of the inserter.But when the inserter is rendered with custom UI (
renderAppender
) it doesn't really use thecanInsertDefaultBlock
value. Therefore, a state update that has no UI effect.This PR fixes that by splitting
BlockListAppender
into multiple components. The outer checks the custom UI and returns immediately when custom UI is requested. Only when custom UI is not requested, does it render an inner component which does theuseSelect
withcanInsertDefaultBlock
.