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

Fix: Embed: Block transformed to a paragraph keeps classes #44947

Closed
wants to merge 1 commit into from

Conversation

petitphp
Copy link
Contributor

@petitphp petitphp commented Oct 13, 2022

What?

Fix #39616. Remove internal css classes, added by the embed block when using some variations like youtube, when transforming the block to another type.

Why?

Related to #38964, the feature allow user-added custom CSS classes to be carried over when transforming blocks. Unfortunately, the Embed block stores its aspect ratio classes as custom CSS classes and they are also kept during transform.

How?

Reusing the same filter as the custom classname support blocks.switchToBlockType.transformedBlock, we apply the removeAspectRatioClasses to the list of classname when transforming an embed block to another type. This allow only remove the aspect ration classes and the keep user-added ones.

Testing Instructions (Base on the instructions from the original issue)

  1. Embed a youtube embed block into any block editor post.
  2. Check the block "Additional CSS classes" field. It should contain the values wp-embed-aspect-16-9 and wp-has-aspect-ratio
  3. Transform the youtube block to a paragraph (ie, paragraph with a linked text)
  4. Check again the block "Additional CSS classes" field. It shouldn't contain the classes wp-embed-aspect-16-9 and wp-has-aspect-ratio anymore

@petitphp petitphp requested a review from ajitbohra as a code owner October 13, 2022 17:29
@skorasaurus skorasaurus added the [Feature] Block Transforms Block transforms from one block to another label Nov 14, 2022
@skorasaurus skorasaurus added the [Block] Embed Affects the Embed Block label Apr 18, 2023
Copy link

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: petitphp <[email protected]>
Co-authored-by: ZebulanStanphill <[email protected]>
Co-authored-by: kathrynwp <[email protected]>
Co-authored-by: ndiego <[email protected]>
Co-authored-by: jorgefilipecosta <[email protected]>
Co-authored-by: ts-mz <[email protected]>

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

@Mamaduka
Copy link
Member

Closing in favor of #68721.

@Mamaduka Mamaduka closed this Jan 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Embed Affects the Embed Block [Feature] Block Transforms Block transforms from one block to another
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Embed: Block transformed to a paragraph keeps classes
3 participants