Skip to content
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

Small optimization for Heading levels block transform and to - from Paragraph block transform #60949

Closed
afercia opened this issue Apr 22, 2024 · 0 comments · Fixed by #60955
Closed
Assignees
Labels
[Package] Block library /packages/block-library [Status] In Progress Tracking issues with work in progress [Type] Enhancement A suggestion for improvement.

Comments

@afercia
Copy link
Contributor

afercia commented Apr 22, 2024

Description

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'.

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.

Yes

@afercia afercia added [Type] Enhancement A suggestion for improvement. [Package] Block library /packages/block-library labels Apr 22, 2024
@afercia afercia self-assigned this Apr 22, 2024
@github-actions github-actions bot added the [Status] In Progress Tracking issues with work in progress label Apr 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Package] Block library /packages/block-library [Status] In Progress Tracking issues with work in progress [Type] Enhancement A suggestion for improvement.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant