Skip to content

Cleanup of Class and Style when Font Family is Removed from Font Library #58798

@okmttdhr

Description

@okmttdhr

Description

Changing the font family on a block adds both a class and inline styles to the block when rendered in the browser. This behavior is expected and allows one to select a font family.
However, an issue arises when the font family previously assigned to a block is removed from the Font Library. In such cases, the associated class and inline style remain on the block even though the font is no longer available.

Expected Behavior:
One of the expected behaviors is that when a font family is removed from the Font Library, any block that previously utilized this font should have the default font family set and its associated class and inline style cleaned up.

Step-by-step reproduction instructions

  • Add a new font family from the Font Library modal.
  • Apply this font family to a block and observe the addition of the corresponding class and inline style to the block on the front of the site.
  • Remove the added font family from the Font Library modal.
  • Observe that, despite the absence of the font, the block retains the class and inline style that references the removed font.

Screenshots, screen recording, code snippet

Screenshot 2024-02-08 at 11 16 21

Environment info

Gutenberg >= 17.6

Please confirm that you have searched existing issues in the repo.

Yes

Please confirm that you have tested with all plugins deactivated except Gutenberg.

No

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions