Skip to content

Conversation

@Infinite-Null
Copy link
Contributor

@Infinite-Null Infinite-Null commented Mar 5, 2025

Closes: #69426

What?

Improves spacing in Notice component between content and action buttons.

Why?

The spacing between the main content and action buttons in the Notice component was too tight, and there was no vertical spacing between multiple notice actions.

Screenshots:

Before After
image image

@t-hamano t-hamano added [Type] Bug An existing feature does not function as intended [Package] Components /packages/components labels Mar 6, 2025
@Infinite-Null Infinite-Null marked this pull request as ready for review March 6, 2025 06:54
@Infinite-Null Infinite-Null requested a review from ajitbohra as a code owner March 6, 2025 06:54
@github-actions
Copy link

github-actions bot commented Mar 6, 2025

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: Infinite-Null <[email protected]>
Co-authored-by: aduth <[email protected]>
Co-authored-by: t-hamano <[email protected]>
Co-authored-by: daledupreez <[email protected]>

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

@Infinite-Null
Copy link
Contributor Author

Hi @daledupreez,
I have implemented a fix for the notice component spacing please test it and review it at your convenience.
Thank you.

@Infinite-Null Infinite-Null requested a review from desrosj as a code owner May 12, 2025 06:06
@Infinite-Null Infinite-Null force-pushed the fix/notice-component-action-spacing branch from 0f81665 to c7db702 Compare May 13, 2025 07:42
Copy link
Member

@aduth aduth 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 submitting this fix, and apologies for the delay in review. This feels like the right fix for a pretty obviously-broken appearance of actions. I'm going to do a bit more testing before approving, but in general the changes are looking good.

Comment on lines 46 to 48

// When it has better support, this can be replaced
// with column-gap since these are flex items.
Copy link
Member

Choose a reason for hiding this comment

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

We can remove this comment now that we're using gap.

Suggested change
// When it has better support, this can be replaced
// with column-gap since these are flex items.

// When it has better support, this can be replaced
// with column-gap since these are flex items.
margin-right: $grid-unit-10;
margin-top: $grid-unit-10;
Copy link
Member

Choose a reason for hiding this comment

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

Part of me feels it'd be better to have the margin apply to the container of the actions, although based on the current implementation we're aways rendering the actions container even if there's no actions, and we wouldn't want the extra margin if there's no actions.

In my opinion we probably shouldn't be rendering that container if there's no actions and then it'd be fine to apply the styling, but that's a bit more extensive change.

@aduth
Copy link
Member

aduth commented Nov 21, 2025

Curious why you chose to remove the CHANGELOG entry in 38fe1a4 ? It seems like it'd be a nice bug fix to highlight.

// When it has better support, this can be replaced
// with column-gap since these are flex items.
margin-right: $grid-unit-10;
margin-top: $grid-unit-10;
Copy link
Member

Choose a reason for hiding this comment

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

Referencing the Figma designs for this component, I think this margin should be $grid-unit-15 (12px) instead of $grid-unit-10 (8px), consistent with the gap between each action button.

Suggested change
margin-top: $grid-unit-10;
margin-top: $grid-unit-15;

@aduth aduth force-pushed the fix/notice-component-action-spacing branch from 38fe1a4 to 8606b17 Compare November 21, 2025 14:33
Copy link
Member

@aduth aduth left a comment

Choose a reason for hiding this comment

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

I pushed a couple changes to your branch from the feedback I had, but I think this is looking great 👍

@Infinite-Null How do you feel about the additional changes I included, notably around only rendering the actions container when there are actions to be shown?

@aduth aduth requested a review from manzoorwanijk November 21, 2025 14:36
@aduth aduth requested a review from a team December 1, 2025 17:30
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.

This PR works fine for the Notice component alone, but in the NoticeList component, the spacing is larger than intended.

For example, open a post editor and run the following code in your browser console:

Details
wp.data.dispatch( 'core/notices' ).createNotice( 'warning', 'Post published.', {
	isDismissible: true,
	actions: [
		{
			label: 'Click me!',
			variant: 'primary',
		},
		{
			label: 'Or click me instead!',
		},
		{
			label: 'Or visit a link for more info',
			url: 'https://wordpress.org',
			variant: 'link',
		},
		{
			label: 'Click me!',
			variant: 'primary',
		},
		{
			label: 'Or click me instead!',
		},
		{
			label: 'Or visit a link for more info',
			url: 'https://wordpress.org',
			variant: 'link',
		},
	],
} );

trunk

Image

This PR

Image

I think we can now remove the style here as well:

.components-notice__action.components-button {
display: block;
margin-left: 0;
margin-top: $grid-unit-10;
}

Image

@aduth aduth force-pushed the fix/notice-component-action-spacing branch from d18fc81 to 01fee66 Compare December 2, 2025 17:01
@aduth
Copy link
Member

aduth commented Dec 2, 2025

Good catch @t-hamano . I removed that spacing style in 1713253 (and additional unnecessary styling in 01fee66). I also updated the Storybook stories for the NoticeList component to include a notice that has actions (19f1abb). Finally, your screenshots show another issue around vertical centering when both buttons and links are included, which should be fixed in 9bd3de3.

Before After
before screenshot after screenshot

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! It looks good on the post editor as well.

Before After
Image Image

@aduth aduth merged commit ba44fa2 into WordPress:trunk Dec 3, 2025
35 checks passed
@github-actions github-actions bot added this to the Gutenberg 22.3 milestone Dec 3, 2025
@aduth
Copy link
Member

aduth commented Dec 3, 2025

Thanks @Infinite-Null for the fix, and @t-hamano for the review 🙌

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

Labels

[Package] Components /packages/components [Type] Bug An existing feature does not function as intended

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Poor spacing for NoticeActions in Notice component

3 participants