-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Avatar Block Exceeds Editor Width When 'Link to User Profile' Option is Enabled #69349
base: trunk
Are you sure you want to change the base?
Avatar Block Exceeds Editor Width When 'Link to User Profile' Option is Enabled #69349
Conversation
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 If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.
To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
👋 Thanks for your first Pull Request and for helping build the future of Gutenberg and WordPress, @Mukulsingh27! 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. |
@t-hamano Old Markup <a href="#avatar-pseudo-link" class="wp-block-avatar__link">
<div tabindex="0" draggable="true" class="block-editor-block-list__block wp-block is-selected wp-block-avatar" id="block-4f9782c1-5c00-4bc0-93a2-d4266615a10c" role="document" aria-label="Block: Avatar" data-block="4f9782c1-5c00-4bc0-93a2-d4266615a10c" data-type="core/avatar" data-title="Avatar">
<div class="components-resizable-box__container has-show-handle" style="position: relative; user-select: auto; width: 96px; height: 96px; max-width: 240px; box-sizing: border-box; flex-shrink: 0;">
<img src="https://secure.gravatar.com/avatar/729ae85bf62b9917e93538db2f2688ca?d=mm&r=g&s=192" alt="mukul Avatar" class="avatar avatar-96 photo wp-block-avatar__image">
</div>
</div>
</a> New Markup <div tabindex="0" draggable="true" class="block-editor-block-list__block wp-block is-selected wp-block-avatar" id="block-91bef366-fbcd-4e55-a0c3-b2d68ed5e3e5" role="document" aria-label="Block: Avatar" data-block="91bef366-fbcd-4e55-a0c3-b2d68ed5e3e5" data-type="core/avatar" data-title="Avatar">
<a href="#avatar-pseudo-link" class="wp-block-avatar__link">
<div class="components-resizable-box__container has-show-handle" style="position: relative; user-select: auto; width: 96px; height: 96px; max-width: 240px; box-sizing: border-box; flex-shrink: 0;">
<img src="https://secure.gravatar.com/avatar/729ae85bf62b9917e93538db2f2688ca?d=mm&r=g&s=192" alt="mukul Avatar" class="avatar avatar-96 photo wp-block-avatar__image">
</div>
</a>
</div> |
There was a problem hiding this 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!
The change looks very good, but we will need to address three issues this change introduces.
- The cursor changes to a pointer when the image is linked. Like other linked blocks, the editor should use the default cursor.
- We can't click on the block "properly". The blue outline doesn't appear when we click on the block, because that would mean we click on the a element.
- The
a
element is 100% wide. The width of thea
element should match the width of the image, just like in the frontend.
f7975efbc77c5f46561ee02c8c81aaa6.mp4
For the first and second issues, we will need styles like this in the editor, just like in the Site Logo block:
.wp-block-avatar__link {
pointer-events: none;
}
For the third issue, we could use the approach in this comment. We will need this style in both the frontend and the editor:
.wp-block-avatar__link {
display: block;
justify-self: start;
}
Thanks @t-hamano for testing and providing the feedback.
The cursor is now fixed across the block. However, if we use
This is now fixed. The blue outline is appearing and working fine.
If we use these properties: .wp-block-avatar__link {
display: block;
justify-self: start;
} Then I doubt that the Untitled.movMade necessary changes to fix all the issues. |
@Mukulsingh27 Thanks for the update!
This approach is fine, but it is not recommended to rely on selectors for specific components. What do you think about changing the following configuration, like for the Site Logo block? <div class="block-editor-block-list__block wp-block wp-block-avatar">
<div class="components-resizable-box__container>
<a href="#avatar-pseudo-link" class="wp-block-avatar__link">
<img class="wp-block-avatar__image">
</a>
</div>
</div>
Sorry, this approach was certainly not appropriate. The problems with this approach were recently discussed here: |
Thanks @t-hamano for sharing the configuration. Screen.Recording.2025-03-04.at.5.33.39.PM.mov |
What?
Closes #69180
It fixes the Avatar block width issue in the editor when the "Link to User Profile" option is enabled. Currently, the block extends beyond the editor's maximum width constraints while maintaining correct frontend display.
Why?
The Avatar block's wrapper element is not properly constrained within the editor's width boundaries when the link option is enabled. This creates an inconsistent editing experience, though the frontend display remains unaffected. The fix ensures visual consistency between the editor and frontend rendering.
How?
Testing Instructions
Testing Instructions for Keyboard
Link to User Profile
optionScreenshots or screencast