Skip to content

Remove inline-block display from image anchor in style.scss - #67368

Merged
t-hamano merged 2 commits into
WordPress:trunkfrom
yogeshbhutkar:67366-fix-line-breaks
Dec 2, 2024
Merged

t-hamano merged 2 commits into
WordPress:trunkfrom
yogeshbhutkar:67366-fix-line-breaks

Conversation

@yogeshbhutkar

@yogeshbhutkar yogeshbhutkar commented Nov 28, 2024 •

Copy link
Copy Markdown
Contributor

Fixes: #67366

What?

This PR removes the display: inline-block property from the image anchor that causes the caption anchors to not flow in continuation as described in the PR.

How?

The CSS rule causing the side-effect was removed.

Screenshots

Before:
Screenshot 2024-11-28 at 12 37 31 PM

After:
Screenshot 2024-11-28 at 12 38 50 PM

Screencast:

Screen.Recording.2024-11-28.at.12.32.16.PM.mov

@yogeshbhutkar
yogeshbhutkar marked this pull request as ready for review November 28, 2024 07:03
@github-actions

github-actions Bot commented Nov 28, 2024 •

Copy link
Copy Markdown

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: yogeshbhutkar <yogeshbhutkar@git.wordpress.org>
Co-authored-by: t-hamano <wildworks@git.wordpress.org>
Co-authored-by: Infinite-Null <ankitkumarshah@git.wordpress.org>
Co-authored-by: hanneslsm <hanneslsm@git.wordpress.org>
Co-authored-by: frkly <frkly@git.wordpress.org>

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

@t-hamano t-hamano added [Type] Bug An existing feature does not function as intended [Block] Image Affects the Image Block labels Nov 29, 2024
@t-hamano

Copy link
Copy Markdown
Contributor

Thanks for the PR!

When deleting code, it's a good idea to use something like Git blame to find out why it's there. This code is to fix the unintended focus outline that occurs when images are linked, so we can't delete this code entirely (See #62556):

image

More importantly, the HTML changes when we add left/right alignment to images in the classic theme.

No left/right alignment:

<figure class="wp-block-image">
  <a href="">
    <img>
  </a>
</figure>

With left:right alignment:

<div class="wp-block-image">
  <figure class="alignleft">
    <a href="">
      <img>
    </a>
  </figure>
</div>

With these things in mind, I think the following selector would be good to accurately target links to the image itself:

.wp-block-image {
	> a,
	> figure > a {
		display: inline-block;
	}
}

@t-hamano

Copy link
Copy Markdown
Contributor

P.S. This issue also occurs when the images are wide and full width, but those issues will be fixed in #67392.

@yogeshbhutkar

Copy link
Copy Markdown
Contributor Author

Thank you, @t-hamano, for reviewing the PR. I have addressed your feedback and made the necessary updates. The code has been tested and is functioning as expected. It is now ready for your review.

Screenshot 2024-12-02 at 2 00 17 PM

@t-hamano
t-hamano self-requested a review December 2, 2024 09:04

@t-hamano t-hamano left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM 👍

@t-hamano
t-hamano merged commit 2f670d5 into WordPress:trunk Dec 2, 2024
@github-actions github-actions Bot added this to the Gutenberg 19.9 milestone Dec 2, 2024
im3dabasia pushed a commit to im3dabasia/gutenberg that referenced this pull request Dec 4, 2024
…s#67368)

* Remove inline-block display from image anchor in style.scss

* Refactor: Set image anchor display to inline-block in style.scss

Co-authored-by: yogeshbhutkar <yogeshbhutkar@git.wordpress.org>
Co-authored-by: t-hamano <wildworks@git.wordpress.org>
Co-authored-by: Infinite-Null <ankitkumarshah@git.wordpress.org>
Co-authored-by: hanneslsm <hanneslsm@git.wordpress.org>
Co-authored-by: frkly <frkly@git.wordpress.org>
michalczaplinski pushed a commit that referenced this pull request Dec 5, 2024
* Remove inline-block display from image anchor in style.scss

* Refactor: Set image anchor display to inline-block in style.scss

Co-authored-by: yogeshbhutkar <yogeshbhutkar@git.wordpress.org>
Co-authored-by: t-hamano <wildworks@git.wordpress.org>
Co-authored-by: Infinite-Null <ankitkumarshah@git.wordpress.org>
Co-authored-by: hanneslsm <hanneslsm@git.wordpress.org>
Co-authored-by: frkly <frkly@git.wordpress.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Block] Image Affects the Image Block [Type] Bug An existing feature does not function as intended

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unnecessary line breaks within image captions due to display: inline-block; on .wp-block-image a

2 participants