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

.wp-element-caption class incorrectly applied to Quote block <cite> element in Editor #62208

Closed
justintadlock opened this issue Jun 2, 2024 · 4 comments
Labels
[Block] Quote Affects the Quote Block [Type] Bug An existing feature does not function as intended

Comments

@justintadlock
Copy link
Contributor

justintadlock commented Jun 2, 2024

Description

Since the addition of the toggle button to show/hide the Quote citation in the editor in Gutenberg 18.1, it has applied the .wp-element-caption class to the <cite> element: #59073

It creates inconsistent styling between the editor and front end because of the addition of the class, which means that it picks up caption styling (it should only have cite styling in both places)

Step-by-step reproduction instructions

  1. Add a Quote block with a citation.
  2. Test on WordPress/Gutenberg pre-18.1.
  3. Test on Gutenberg 18.1 or newer and see the addition of the .wp-element-caption class on the editor side.

Screenshots, screen recording, code snippet

Editor:

quote-cite-editor

Front end:

quote-cite-front-end

Environment info

  • WordPress trunk
  • Gutenberg 18.5 RC1

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

@justintadlock justintadlock added [Type] Bug An existing feature does not function as intended [Block] Quote Affects the Quote Block labels Jun 2, 2024
@aatanasovdev
Copy link
Contributor

aatanasovdev commented Jun 10, 2024

For the <cite> element, the Quote block relies on a utility component called Caption, which is used by other blocks such as Video, Gallery, etc. It was prepared in this pull request.

The front end doesn't have the .wp-element-caption because the save method doesn't use __experimentalGetElementClassName( 'caption' ) as it is done for the other blocks.

Based on that, we have the following approaches:

  1. If we need to reuse the existing Caption utility component, it is better if we use the .wp-element-caption class in the Editor and on the front end.
  2. We create a new component for the <cite> element.

The second option will be appropriate if we don't consider the citation as a caption and then reuse the new component for other <cite> related places in the future. Otherwise, the first option makes sense for better consistency.

@justintadlock
Copy link
Contributor Author

If we need to reuse the existing Caption utility component, it is better if we use the .wp-element-caption class in the Editor and on the front end.

This option would also create back-compatibility styling issues for themes. But I'd consider it a non-starter because citations and captions are two different things that serve different purposes

We create a new component for the <cite> element.

Is a new component needed or just the ability to overrule the class of the existing component? I'd be OK with either direction.

@aatanasovdev
Copy link
Contributor

@justintadlock , thank you for the feedback. I've prepared a PR (my first one) following the overrule approach.

In the future, if we end up adding too many options/rules to the utility components, we can think of organizing and standardizing them for better consitency.

@talldan
Copy link
Contributor

talldan commented Jun 17, 2024

Fixed by #62485

@talldan talldan closed this as completed Jun 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Quote Affects the Quote Block [Type] Bug An existing feature does not function as intended
Projects
No open projects
Status: Done
Development

No branches or pull requests

3 participants