Skip to content

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

Closed

Description

@afercia

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

Activity

  1. added
    [Type] Enhancement
    [Package] Block library
    on Apr 22, 2024
  2. self-assigned this
    on Apr 22, 2024
  3. added
    [Status] In Progress
    on Apr 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

[Package] Block library[Status] In Progress[Type] Enhancement

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions