Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
Block Editor: Flatten, shortcut align hook rendering if unaligned #18963
This pull request seeks to optimize the implementation of the block alignment
It seeks to improve performance in two ways:
The aim here is to optimize that the majority of blocks will not have an alignment value, and can skip this hook logic.
There might be some way to optimize this even further:
Verify there are no regressions in the rendering of a block, notably on valid alignments of a block, e.g. in themes with and without wide alignment support (should not show as wide-aligned in the editor if the theme doesn't support it).
Ensure unit tests pass:
@youknowriad I was having some difficulty with the performance test suite yesterday, but I was initially drawn to this code from a Chrome DevTools Performance recording, so there's some space for gains, likely in the 0-3ms range per keypress. I'll see if I can get the tests working today.
I'm still not entirely sure the performance tests are cooperating (and the results are a bit all over the place), but for what I do see, it doesn't seem like this is having too much of an impact for better or worse:
Conceptually, I can't imagine how it could be anything other than an improvement, based on the proposed advantages here. At the very least it could be seen as as a useful refactoring to simplify the implementation of this behavior, and toward consistency of hooks usage and component flattening.