Conversation
`this.props.blocks` doesn't have content until the editor "is ready".
|
cc @koke - This should fix what I mentioned on #643 (review) |
hypest
left a comment
There was a problem hiding this comment.
LGTM!
✅ Check in the Xcode console that the message gutenbergDidMount(hasUnsupportedBlocks: true) is written.
✅ Check that the proper hasUnsupportedBlocks is received in WPAndroid
componentDidUpdate is the best place I found to do this check, but sending hasUnsupportedBlocks as part of the editorDidMount (from componentDidUpdate) feels not optimal.
I guess I wouldn't worry too much about his since the "editor mount" can have various meanings since it's not a proper React lifecycle method name. We can leave it as is until we trip on it and then rename.
|
Thank you @hypest ! |
|
I'm fine with this as a hotfix, but also not super happy with the naming of things. I think it's OK if we need to abandon the I am concerned that What if a future refactor changes the behaviour again and everything is ready on |
|
I agree! |
|
I'd prefer if we don't expose/bubble RN/React lifecycle events to the parents, as it makes it hard to understand what the intention is by looking at the interface. Instead, the interface to the parents should be as close as possible to certain functionalities. We already do various things in wpandroid based on the |
|
Ah oh, by the way, great job adding a test for the regression @etoledom ! 👏 |
This PR fixes a problem where the
hasUnsupportedBlockssent to the native apps was alwaysfalse.The reason is that after this refactor, the block list is not available on
AppContaineruntil the "editor is ready", thusthis.props.blockswill always be empty oncomponentDidMount.The solution is to wait for
props.isReadyto be true to check and sendhasUnsupportedBlockswith the appropriate value.Note:
componentDidUpdateis the best place I found to do this check, but sendinghasUnsupportedBlocksas part of theeditorDidMount(fromcomponentDidUpdate) feels not optimal. I'm open to suggestions (as always). But as a hotfix, it works.editorDidMountmessage sent to native, but I'd prefer to do it on a separate PR on develop, since it will require native code on both platforms to be modified.editorDidMountand create a separate message specific forhasUnsupportedBlocks.Note 2: After it's approved, I'll create a new JS Bundle before merging.
To test:
open ios/gutenberg.xcodeproj).gutenbergDidMount(hasUnsupportedBlocks: true)is written.hasUnsupportedBlocksis received.