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

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

Closed
okmttdhr opened this issue Feb 8, 2024 · 2 comments
Closed
Labels
[Feature] Font Library [Type] Bug An existing feature does not function as intended

Comments

@okmttdhr
Copy link
Contributor

okmttdhr commented Feb 8, 2024

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

@okmttdhr okmttdhr added [Type] Bug An existing feature does not function as intended [Feature] Font Library labels Feb 8, 2024
@matiasbenedetto
Copy link
Contributor

👋 thanks for testing and submitting issues @okmttdhr ! :)

I think this is the expected behavior. It works as any other theme.json setting: any setting added to theme.json that's applied to an element but after that removed from theme.json file will act the same way. If the setting is re-added, the element render as expected. With fonts, it happens the same; if a font is installed, applied to elements, uninstalled, and finally installed again, the elements will display the font as expected. Removing the class would result in the element won't display it, which seems unexpected.

This is mostly unrelated to the font library functionality and depends on how global styles and styles engine work.

If this rationale makes sense, I propose to close this issue.

@okmttdhr
Copy link
Contributor Author

okmttdhr commented Feb 9, 2024

That makes totally sense to me 🙂 Closing the issue.

@okmttdhr okmttdhr closed this as completed Feb 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Font Library [Type] Bug An existing feature does not function as intended
2 participants