You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Small optimization for Heading levels block transform and to - from Paragraph block transform #60949
After #60606 the code responsible for transforming heading levels and to - from paragraph is centralised in a unique place. This makes easier to add a small optimization and avoid to run a block transform when not necessary.
When using the keybaord shortcuts to change heading levels or transform to - from paragraph, there is no check whether the heading already has the destination level or whether the block is already a paragraph or heading.
That is, for example:
Pressing Control + Option + 2 on a Heading block that already has a level 2 runs the block transform anyways.
Pressing Control + Option + 0 or 7 on a Paragraph block runs the block transform 'to Paragraph' anyways.
Running code to transform a block to the same block type / level is unnecessary and should be avoided.
The performance optimization would be minimal but still nice.
Visually, this would would reduce some 'flickering' in the settings panel. That's triggered for any block transform but it should be avoided when the transform is not necessary. See attached GIF thtat illustrates the 'flickering'.
Step-by-step reproduction instructions
Edit a post and add a Heading block with level 2.
Select the heading block.
Press Control + Option + 2 (on macOS) or Control + Alt + 2 (on Windows).
Observe the Settings panel and see the quick 'flickering' of the UI.
Screenshots, screen recording, code snippet
No response
Environment info
No response
Please confirm that you have searched existing issues in the repo.
Yes
Please confirm that you have tested with all plugins deactivated except Gutenberg.
Activity