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

Caption utility component: Allow the main CSS Class Name to be excluded from the markup. #62485

Merged

Conversation

aatanasovdev
Copy link
Contributor

@aatanasovdev aatanasovdev commented Jun 11, 2024

What?

Extending the Caption utility component by allowing the main CSS Class Name to be excluded from the HTML Markup using a prop called excludeElementClassName. Also, the Quote block was modified to use the prop.

Why?

This update is related to this issue: 62208

The new prop allows us to reuse the existing Caption component in places where its main CSS Class Name (.wp-element-caption) isn't needed.

How?

It addresses the issue by adding a prop to the Caption component, which excludes the main CSS Class Name when needed.

Testing Instructions

  1. Insert a Quote block with a citation.
  2. Inspect the HTML markup of the block.
  3. The wp-element-caption CSS Class Name shouldn't exist in the <cite> element.
  4. Insert a Gallery block with some images and add captions to them.
  5. Inspect the HTML markup of an image caption.
  6. The wp-element-caption CSS Class Name should exist in the <figcaption> element.
Copy link

github-actions bot commented Jun 11, 2024

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: aatanasovdev <aatanasov@git.wordpress.org>
Co-authored-by: talldan <talldanwp@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@github-actions github-actions bot added the First-time Contributor Pull request opened by a first-time contributor to Gutenberg repository label Jun 11, 2024
Copy link

👋 Thanks for your first Pull Request and for helping build the future of Gutenberg and WordPress, @aatanasovdev! In case you missed it, we'd love to have you join us in our Slack community.

If you want to learn more about WordPress development in general, check out the Core Handbook full of helpful information.

@aatanasovdev aatanasovdev changed the title Allow the main CSS class name of the Caption utility component to be … Jun 11, 2024
@aatanasovdev
Copy link
Contributor Author

Regarding the failed tests:

  • Enforce labels on Pull Request: I missed adding the necessary labels: [Block] Quote and [Type] Bug
  • React Native E2E Tests (Android) / Unit Tests / JavaScript (Node.js 22) 2/4 Reviewing the details, it appears the errors aren't related to the PR code itself, and I'm not sure if any actions should be done for these two in this PR.
Copy link
Contributor

@talldan talldan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for working on this change!

The code looks good to me, but I think the prop naming could be simplified a little.

It doesn't really affect the functionality though, so I'll approve it.

@@ -32,6 +32,7 @@ export function Caption( {
placeholder = __( 'Add caption' ),
label = __( 'Caption text' ),
showToolbarButton = true,
excludeMainElementClassName,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the naming of the prop could be simplified:

Suggested change
excludeMainElementClassName,
excludeElementClassName,
@talldan talldan added [Type] Bug An existing feature does not function as intended [Block] Quote Affects the Quote Block labels Jun 13, 2024
@aatanasovdev
Copy link
Contributor Author

@talldan, thank you for approving the change and suggesting a simplified prop name.

I've pushed a new commit with the simplified name.

@talldan talldan added the Backport to WP 6.6 Beta/RC Pull request that needs to be backported to the WordPress major release that's currently in beta label Jun 17, 2024
@talldan
Copy link
Contributor

talldan commented Jun 17, 2024

Thanks @aatanasovdev for your contribution.

There's a unit test failure related to the caniuse dependency being outdated, but this is happening in trunk too, so I'll go ahead and merge the PR and look to fix those failures separately (fixed in #62611).

@talldan talldan merged commit 11390a8 into WordPress:trunk Jun 17, 2024
54 of 62 checks passed
@github-actions github-actions bot added this to the Gutenberg 18.7 milestone Jun 17, 2024
patil-vipul pushed a commit to patil-vipul/gutenberg that referenced this pull request Jun 17, 2024
…ed from the markup. (WordPress#62485)

* Allow the main CSS class name of the Caption utility component to be excluded in the HTML markup

* Caption utility component: change the name of the property responsible for excluding the Element CSS Class Name

----

Co-authored-by: aatanasovdev <aatanasov@git.wordpress.org>
Co-authored-by: talldan <talldanwp@git.wordpress.org>
huubl pushed a commit to huubl/gutenberg that referenced this pull request Jun 17, 2024
…ed from the markup. (WordPress#62485)

* Allow the main CSS class name of the Caption utility component to be excluded in the HTML markup

* Caption utility component: change the name of the property responsible for excluding the Element CSS Class Name

----

Co-authored-by: aatanasovdev <aatanasov@git.wordpress.org>
Co-authored-by: talldan <talldanwp@git.wordpress.org>
ellatrix pushed a commit that referenced this pull request Jun 18, 2024
…ed from the markup. (#62485)

* Allow the main CSS class name of the Caption utility component to be excluded in the HTML markup

* Caption utility component: change the name of the property responsible for excluding the Element CSS Class Name

----

Co-authored-by: aatanasovdev <aatanasov@git.wordpress.org>
Co-authored-by: talldan <talldanwp@git.wordpress.org>
ellatrix pushed a commit that referenced this pull request Jun 18, 2024
…ed from the markup. (#62485)

* Allow the main CSS class name of the Caption utility component to be excluded in the HTML markup

* Caption utility component: change the name of the property responsible for excluding the Element CSS Class Name

----

Co-authored-by: aatanasovdev <aatanasov@git.wordpress.org>
Co-authored-by: talldan <talldanwp@git.wordpress.org>
@ellatrix
Copy link
Member

I just cherry-picked this PR to the wp/6.6-beta-3 branch to get it included in the next release: b6178b7

@ellatrix ellatrix added Backported to WP Core Pull request that has been successfully merged into WP Core and removed Backport to WP 6.6 Beta/RC Pull request that needs to be backported to the WordPress major release that's currently in beta labels Jun 18, 2024
ellatrix pushed a commit that referenced this pull request Jun 18, 2024
…ed from the markup. (#62485)

* Allow the main CSS class name of the Caption utility component to be excluded in the HTML markup

* Caption utility component: change the name of the property responsible for excluding the Element CSS Class Name

----

Co-authored-by: aatanasovdev <aatanasov@git.wordpress.org>
Co-authored-by: talldan <talldanwp@git.wordpress.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Backported to WP Core Pull request that has been successfully merged into WP Core [Block] Quote Affects the Quote Block First-time Contributor Pull request opened by a first-time contributor to Gutenberg repository [Type] Bug An existing feature does not function as intended
3 participants