Skip to content

Update background image control dropdown height to fit-content#68038

Closed
yogeshbhutkar wants to merge 71 commits into
WordPress:trunkfrom
yogeshbhutkar:68029-fix-button-spacing-issue
Closed

Update background image control dropdown height to fit-content#68038
yogeshbhutkar wants to merge 71 commits into
WordPress:trunkfrom
yogeshbhutkar:68029-fix-button-spacing-issue

Conversation

@yogeshbhutkar

@yogeshbhutkar yogeshbhutkar commented Dec 17, 2024

Copy link
Copy Markdown
Contributor

Fixes: #68029

What?

This PR contains a patch for fixing spacing inconsistency in the background image selector button.

How?

As the issue description mentions, the default size of Toolbar Button was updated to compact, whose styles are applied using the is-compact classname.

The is-compact classname contains a height of 32px as mentioned here:

height: $button-size-compact;

$button-size-compact: 32px;

Whereas, the heights described in .components-dropdown applied to its parent, is actually 36px leading to a mismatch in the parent container and child's heights.

To fix the issue, the heights are updated inside .components-dropdown to now use fit-content instead of using the previously hardcoded value 36px.

As an alternative, we can also hardcode the height to 32px.

File Changed:

> packages/block-editor/src/components/background-image-control/style.scss

Testing Instructions

  1. Go to the site editor.
  2. Click on "Styles"
  3. Click on "Background"
  4. Confirm that the spacing for the button is now correct.

Screenshots

Before After
Screenshot 2024-12-17 at 10 38 17 AM Screenshot 2024-12-17 at 10 37 24 AM

@yogeshbhutkar yogeshbhutkar marked this pull request as ready for review December 17, 2024 05:14
@github-actions

github-actions Bot commented Dec 17, 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: tyxla <tyxla@git.wordpress.org>
Co-authored-by: Sukhendu2002 <sukhendu2002@git.wordpress.org>
Co-authored-by: jorgefilipecosta <jorgefilipecosta@git.wordpress.org>
Co-authored-by: Mamaduka <mamaduka@git.wordpress.org>
Co-authored-by: jsnajdr <jsnajdr@git.wordpress.org>
Co-authored-by: prasadkarmalkar <prasadkarmalkar@git.wordpress.org>
Co-authored-by: afercia <afercia@git.wordpress.org>
Co-authored-by: manzoorwanijk <manzoorwanijk@git.wordpress.org>
Co-authored-by: t-hamano <wildworks@git.wordpress.org>
Co-authored-by: himanshupathak95 <abcd95@git.wordpress.org>
Co-authored-by: mirka <0mirka00@git.wordpress.org>
Co-authored-by: Mayank-Tripathi32 <mayanktripathi32@git.wordpress.org>
Co-authored-by: Infinite-Null <ankitkumarshah@git.wordpress.org>
Co-authored-by: oandregal <oandregal@git.wordpress.org>
Co-authored-by: Vrishabhsk <vrishabhsk@git.wordpress.org>
Co-authored-by: mikachan <mikachan@git.wordpress.org>
Co-authored-by: im3dabasia <im3dabasia1@git.wordpress.org>
Co-authored-by: akasunil <sunil25393@git.wordpress.org>
Co-authored-by: mayurprajapatii <mayur8991@git.wordpress.org>
Co-authored-by: tellthemachines <isabel_brison@git.wordpress.org>
Co-authored-by: swissspidy <swissspidy@git.wordpress.org>
Co-authored-by: ciampo <mciampini@git.wordpress.org>
Co-authored-by: dd32 <dd32@git.wordpress.org>
Co-authored-by: sirreal <jonsurrell@git.wordpress.org>
Co-authored-by: ntsekouras <ntsekouras@git.wordpress.org>
Co-authored-by: getdave <get_dave@git.wordpress.org>
Co-authored-by: sarthaknagoshe2002 <sarthaknagoshe2002@git.wordpress.org>
Co-authored-by: juanfra <juanfra@git.wordpress.org>
Co-authored-by: rohitmathur-7 <rohitmathur7@git.wordpress.org>
Co-authored-by: talldan <talldanwp@git.wordpress.org>
Co-authored-by: hbhalodia <hbhalodia@git.wordpress.org>
Co-authored-by: benazeer-ben <benazeer@git.wordpress.org>

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

@juanfra juanfra added the [Type] Bug An existing feature does not function as intended label Dec 17, 2024
@juanfra juanfra requested review from mirka and tyxla December 17, 2024 12:23
@juanfra

juanfra commented Dec 17, 2024

Copy link
Copy Markdown
Member

Thank you for the PR!

I believe this button isn’t meant to use the compact style. It seems like the transition to the new 40px size would make sense to keep things cohesive with other elements in the styles section. I’d love to hear what the components maintainers think about this!

@Mamaduka Mamaduka added the [Package] Block editor /packages/block-editor label Dec 17, 2024

@mirka mirka left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I don't quite understand — why is this button a ToolbarButton? At first glance it looks like there's some hacky reuse of MediaReplaceFlow, which is not fully appropriate for this context since we're not inside a Toolbar. There's probably some refactoring to be done if we want to reuse it outside of a Toolbar.

I'll also note that the correct height for this Button is 40px.

@yogeshbhutkar

yogeshbhutkar commented Dec 18, 2024

Copy link
Copy Markdown
Contributor Author

Hi @mirka, thank you for reviewing the PR! You’re absolutely right, the MediaReplaceFlow component is used in several places. In almost all cases, it’s appropriately placed within a Toolbar. However, in BackgroundImageControls, it’s not used inside a Toolbar, making the current implementation unsuitable for this context.

To address this, I explored a few ways to refactor the MediaReplaceFlow component. I believe introducing a buttonVariant prop is the most effective solution. This allows us to conditionally render either a Button or a ToolbarButton based on the prop, which can be set as needed for each use case.

I’ve implemented these changes and would love to hear your thoughts or suggestions for further improvement!

Here's a recent screenshot demonstrating that the recent changes fix the issue:
Screenshot 2024-12-18 at 11 09 21 AM

Audio Toolbar is one of the many places that implement the MediaReplaceFlow component and expects ToolbarButton. Here's a screenshot of it working as expected after the latest commit.
Screenshot 2024-12-18 at 12 25 45 PM

CC: @mirka @juanfra

Comment on lines +43 to +44
default: ToolbarButton,
toolbar: ToolbarButton,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Leaving the final review to @mirka, but just a side note here.

I'd personally remove default and just make buttonVariant default to toolbar. No need to maintain two variants that do the same thing.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Hi @tyxla, I was running into a Webpack build error and had to rebase to trunk but ran into an issue while rebasing. I've incorporated the changes suggested here by you and have opened a new PR here. #68084

Apologies for the inconvenience caused.

tyxla and others added 16 commits December 18, 2024 14:35
Co-authored-by: tyxla <tyxla@git.wordpress.org>
Co-authored-by: jameskoster <jameskoster@git.wordpress.org>
Co-authored-by: mirka <0mirka00@git.wordpress.org>
…PanelBody (WordPress#67906)

Co-authored-by: Sukhendu2002 <sukhendu2002@git.wordpress.org>
Co-authored-by: fabiankaegy <fabiankaegy@git.wordpress.org>
Co-authored-by: jorgefilipecosta <jorgefilipecosta@git.wordpress.org>
Co-authored-by: shail-mehta <shailu25@git.wordpress.org>
…ordPress#67879)

* Plugin: Fix eligibility check for post types' default rendering mode
* Add backport changelog entry

Unlinked contributors: CreativeDive.

Co-authored-by: Mamaduka <mamaduka@git.wordpress.org>
Co-authored-by: fabiankaegy <fabiankaegy@git.wordpress.org>
…cks docs (WordPress#67889)

Co-authored-by: jorgefilipecosta <jorgefilipecosta@git.wordpress.org>
Co-authored-by: shail-mehta <shailu25@git.wordpress.org>
* Create a catalog list of private APIs

* Document some private components

* Rewrite the introduction

* Rewrite the introduction again
…of PanelBody (WordPress#67910)

Co-authored-by: prasadkarmalkar <prasadkarmalkar@git.wordpress.org>
Co-authored-by: fabiankaegy <fabiankaegy@git.wordpress.org>
…f PanelBody (WordPress#67913)

Co-authored-by: prasadkarmalkar <prasadkarmalkar@git.wordpress.org>
Co-authored-by: fabiankaegy <fabiankaegy@git.wordpress.org>
…ordPress#67817)


Co-authored-by: afercia <afercia@git.wordpress.org>
Co-authored-by: oandregal <oandregal@git.wordpress.org>
Co-authored-by: manzoorwanijk <manzoorwanijk@git.wordpress.org>
Co-authored-by: youknowriad <youknowriad@git.wordpress.org>
Co-authored-by: anomiex <bjorsch@git.wordpress.org>
…nuItem' (WordPress#67961)


Co-authored-by: Mamaduka <mamaduka@git.wordpress.org>
)

* Improve logic to show entities saved panel description.

* Apply CR suggestion

---------

Co-authored-by: afercia <afercia@git.wordpress.org>
Co-authored-by: Mamaduka <mamaduka@git.wordpress.org>
Co-authored-by: t-hamano <wildworks@git.wordpress.org>
…#67880)

Co-authored-by: t-hamano <wildworks@git.wordpress.org>
Co-authored-by: tyxla <tyxla@git.wordpress.org>
Co-authored-by: jameskoster <jameskoster@git.wordpress.org>
…ess#67371)

* Storybook: Add stories for the text-alignment-control component

* Storybook: Update TextAlignmentControl story to follow best practices and simplify the structure

* Storybook: Simplify TextAlignmentControl story

* Storybook: Simplify the documentation for TextAlignmentControl story

Co-authored-by: himanshupathak95 <abcd95@git.wordpress.org>
Co-authored-by: t-hamano <wildworks@git.wordpress.org>
* TreeSelect: Deprecate 36px default size

* Fix types

* Auto-generate readme

* Add changelog

* Fixup readme

Co-authored-by: mirka <0mirka00@git.wordpress.org>
Co-authored-by: tyxla <tyxla@git.wordpress.org>
…ad of PanelBody (WordPress#67898)

Co-authored-by: Sukhendu2002 <sukhendu2002@git.wordpress.org>
Co-authored-by: fabiankaegy <fabiankaegy@git.wordpress.org>
rohitmathur-7 and others added 14 commits December 18, 2024 14:35
…ecific contexts (WordPress#67738)

* Remove patterns from quick inserter

* Remove commented code

* Removed prioritizePatterns instances where possible

----

Co-authored-by: rohitmathur-7 <rohitmathur7@git.wordpress.org>
Co-authored-by: talldan <talldanwp@git.wordpress.org>
Co-authored-by: richtabor <richtabor@git.wordpress.org>
)


Co-authored-by: Mamaduka <mamaduka@git.wordpress.org>
Co-authored-by: talldan <talldanwp@git.wordpress.org>
…MenuProps hook for placement (WordPress#68019)

Co-authored-by: im3dabasia <im3dabasia1@git.wordpress.org>
Co-authored-by: fabiankaegy <fabiankaegy@git.wordpress.org>
…nformation) (WordPress#65641)

* Use Badge for the block type

* Wrap when custom name is long enough

* Fix calc

Co-authored-by: getdave <get_dave@git.wordpress.org>
Co-authored-by: draganescu <andraganescu@git.wordpress.org>
Co-authored-by: mikachan <mikachan@git.wordpress.org>
Co-authored-by: jameskoster <jameskoster@git.wordpress.org>
Co-authored-by: t-hamano <wildworks@git.wordpress.org>
Co-authored-by: jeryj <jeryj@git.wordpress.org>
Co-authored-by: richtabor <richtabor@git.wordpress.org>
…WordPress#68031)

* Hide inserter

* Comment case

Co-authored-by: Sarah Norris <1645628+mikachan@users.noreply.github.com>

---------

Co-authored-by: getdave <get_dave@git.wordpress.org>
Co-authored-by: MaggieCabrera <onemaggie@git.wordpress.org>
Co-authored-by: mikachan <mikachan@git.wordpress.org>
* Fix Choose menu label when a menu has been deleted.

* Pass menu ID to useNavigationMenu.

Co-authored-by: afercia <afercia@git.wordpress.org>
Co-authored-by: ntsekouras <ntsekouras@git.wordpress.org>
Co-authored-by: draganescu <andraganescu@git.wordpress.org>
* Correct spelling

* Fix caps

Co-authored-by: getdave <get_dave@git.wordpress.org>
Co-authored-by: shail-mehta <shailu25@git.wordpress.org>
Co-authored-by: MaggieCabrera <onemaggie@git.wordpress.org>
…Press#65429)

* Add deperecation notice for the ButtonGroup component

* Address the feedbacks for deprecation for ButtonGroupControl

* Add the changelog deprecation message.

* Update the changelog comment

Co-authored-by: hbhalodia <hbhalodia@git.wordpress.org>
Co-authored-by: mirka <0mirka00@git.wordpress.org>
Co-authored-by: ciampo <mciampini@git.wordpress.org>
* ActionItem.Slot: Render as MenuGroup by default

* Add changelog

* Remove redundant `as` rendering in app

Co-authored-by: mirka <0mirka00@git.wordpress.org>
Co-authored-by: ciampo <mciampini@git.wordpress.org>
Co-authored-by: ntsekouras <ntsekouras@git.wordpress.org>
* Add command to navigate to site editor

* No icon, improved label

* Modified code to display command other than Site editor

* Feedback and suggestion updates

---------

Co-authored-by: benazeer-ben <benazeer@git.wordpress.org>
Co-authored-by: richtabor <richtabor@git.wordpress.org>
Co-authored-by: t-hamano <wildworks@git.wordpress.org>
Co-authored-by: annezazu <annezazu@git.wordpress.org>
Co-authored-by: jameskoster <jameskoster@git.wordpress.org>
Co-authored-by: jasmussen <joen@git.wordpress.org>
Co-authored-by: ramonjd <ramonopoly@git.wordpress.org>
…ress#67811)

* Give style book its own route so it can be linked to directly.

* Fix paths to and from global styles.

* Use query instead of path

* Fix path

* Effect for editor settings update
@yogeshbhutkar

Copy link
Copy Markdown
Contributor Author

Hi @juanfra @mirka, I was facing a Webpack build error due to which I had to rebase to Trunk. While doing so, I ran into an issue. I've created a new PR with the patch here: #68084

Let’s continue the discussion there. Apologies for any inconvenience this may have caused.

@juanfra

juanfra commented Dec 18, 2024

Copy link
Copy Markdown
Member

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Package] Block editor /packages/block-editor [Type] Bug An existing feature does not function as intended

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Background image selector button spacing issue