Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Blocks: Try new context API to simplify display of block controls #5029
This PR updated React version to version 16.3.x (once it is stable we can update 15cd537 and move to its own PR). One of the new features that 16.3 is going to introduce is new context API. I gave it a spin to simplify the way we handle
I never liked that we need to prepend those controls with the check for every block. It is very easy to forget about it and it leads to unexpected behaviors. It turns out that this is a quite common issue that people have when learning how to create a new block. This is what I understood when talking to @zgordon. He shared also an example issue where the current logic caused troubles: Duplicate Inspector Controls.
This PR wraps
How Has This Been Tested?
Manually tested if there were no regression. The only block that was upgraded so far is
The best way to test is to add a few paragraphs and make sure the display only their own controls.
I also made sure all unit tests pass (
I really like the idea, this change in addition to the removal of the focus management will make block author's life easier.
I'm always suspicious when it comes to context usage in React in general but I think this is a good usage for it.
referenced this pull request
Feb 13, 2018
I like where this is going. It feels like a good balance of magic, and the reason why it doesn't go overboard is that the abstraction itself makes sense: being in a context of block editing is something that makes sense for the block developer and for the user, and the idea that
@youknowriad I addressed your comment related to
Enzyme update is necessary to make tests work properly. I had to skip some tests and one of the tests behaves strangely (the one for Paragraph).
Apr 16, 2018
Moving forward with this one. There is no easy way to provide a message to the developers that