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

Media & Text block: Fix nested Media & Text block media position issue with increased CSS specificity #62184

Merged
merged 5 commits into from
Jun 1, 2024

Conversation

amitraj2203
Copy link
Contributor

@amitraj2203 amitraj2203 commented May 31, 2024

What?

Fix: #62047

Why?

When we add a Media & Text block and set the media position to the right with the toolbar setting, and then insert a second Media & Text block in the block's content area: Then the media position option in the second Media & Text block does not work.

How?

Adds > to relevant CSS selectors.

Testing Instructions

  1. Insert a Media & Text block.
  2. Set the media position option in the block toolbar to the right.
  3. Insert a second Media & Text block inside the first, and try to set its media position.

Copy link

github-actions bot commented May 31, 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: amitraj2203 <[email protected]>
Co-authored-by: t-hamano <[email protected]>
Co-authored-by: carolinan <[email protected]>

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

@amitraj2203 amitraj2203 changed the title Refactor media-text layout styles Media & Text block: Fix nested Media & Text block media position issue with increased CSS specificity May 31, 2024
@richtabor richtabor added [Block] Media & Text Affects the Media & Text Block [Type] Bug An existing feature does not function as intended labels May 31, 2024
@richtabor richtabor requested review from t-hamano and removed request for tellthemachines and aaronrobertshaw May 31, 2024 14:00
@amitraj2203
Copy link
Contributor Author

The same issue is also happening with the block's vertical alignment: if I change the outer block's vertical alignment to bottom then the inner block's vertical alignment doesn't work. So I have added the> selector to its respective class.

Copy link
Contributor

@t-hamano t-hamano 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 the PR!

This PR works as expected, but we might also want to fix the issue where the layout affects nested blocks when "Stack on mobile" is enabled.

nested-stack-on-mobile

Just make the following changes:

diff --git a/packages/block-library/src/media-text/style.scss b/packages/block-library/src/media-text/style.scss
index d5da67b5e4..8a880fbab4 100644
--- a/packages/block-library/src/media-text/style.scss
+++ b/packages/block-library/src/media-text/style.scss
@@ -108,11 +108,11 @@
 @media (max-width: #{ ($break-small) }) {
        .wp-block-media-text.is-stacked-on-mobile {
                grid-template-columns: 100% !important;
-               .wp-block-media-text__media {
+               > .wp-block-media-text__media {
                        grid-column: 1;
                        grid-row: 1;
                }
-               .wp-block-media-text__content {
+               > .wp-block-media-text__content {
                        grid-column: 1;
                        grid-row: 2;

@amitraj2203
Copy link
Contributor Author

Thanks for reviewing the PR. I apologize for missing this 😅
I have updated the code to address this issue now.

@amitraj2203 amitraj2203 requested a review from t-hamano June 1, 2024 06:20
Copy link
Contributor

@t-hamano t-hamano left a comment

Choose a reason for hiding this comment

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

LGTM!

Before

image

After

image

@t-hamano t-hamano merged commit 77d6943 into WordPress:trunk Jun 1, 2024
62 checks passed
@github-actions github-actions bot added this to the Gutenberg 18.6 milestone Jun 1, 2024
carstingaxion pushed a commit to carstingaxion/gutenberg that referenced this pull request Jun 4, 2024
…e with increased CSS specificity (WordPress#62184)

* Refactor media-text layout styles

* Update media-text alignment styles to support nested media-text blocks

* Update media-text layout for mobile view

Co-authored-by: amitraj2203 <[email protected]>
Co-authored-by: t-hamano <[email protected]>
Co-authored-by: carolinan <[email protected]>
@ellatrix
Copy link
Member

ellatrix commented Jun 7, 2024

Should this be backported for WP 6.6? If so, please add the Backport to WP Beta/RC label. Thanks!

@t-hamano
Copy link
Contributor

t-hamano commented Jun 8, 2024

This issue isn't new to WP6.6, but I think it's a great fix, so let's backport it to WP6.6.

@t-hamano t-hamano added the Backport to WP 6.7 Beta/RC Pull request that needs to be backported to the WordPress major release that's currently in beta label Jun 8, 2024
ellatrix pushed a commit that referenced this pull request Jun 11, 2024
…e with increased CSS specificity (#62184)

* Refactor media-text layout styles

* Update media-text alignment styles to support nested media-text blocks

* Update media-text layout for mobile view

Co-authored-by: amitraj2203 <[email protected]>
Co-authored-by: t-hamano <[email protected]>
Co-authored-by: carolinan <[email protected]>
ellatrix pushed a commit that referenced this pull request Jun 11, 2024
…e with increased CSS specificity (#62184)

* Refactor media-text layout styles

* Update media-text alignment styles to support nested media-text blocks

* Update media-text layout for mobile view

Co-authored-by: amitraj2203 <[email protected]>
Co-authored-by: t-hamano <[email protected]>
Co-authored-by: carolinan <[email protected]>
patil-vipul pushed a commit to patil-vipul/gutenberg that referenced this pull request Jun 17, 2024
…e with increased CSS specificity (WordPress#62184)

* Refactor media-text layout styles

* Update media-text alignment styles to support nested media-text blocks

* Update media-text layout for mobile view

Co-authored-by: amitraj2203 <[email protected]>
Co-authored-by: t-hamano <[email protected]>
Co-authored-by: carolinan <[email protected]>
@ellatrix ellatrix removed the Backport to WP 6.7 Beta/RC Pull request that needs to be backported to the WordPress major release that's currently in beta label Jun 18, 2024
@ellatrix
Copy link
Member

This was cherry-picked to the wp/6.6 branch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Media & Text Affects the Media & Text Block [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Media & text block: When the media is on the right, the media position of a nested block does not work
4 participants