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

Cover Block: Move Clear Media button from Inspector Controls to Block Controls. #64630

Conversation

rohitmathur-7
Copy link
Contributor

@rohitmathur-7 rohitmathur-7 commented Aug 20, 2024

What?

  • Move the Clear Media button from Inspector Controls to Block Controls for better UX.

Fixes: #64629

Why?

  • The Clear Media button should be present in Block Controls alongside Replace button so that all the buttons related to the media are present in one place only.

How?

  • Move the Button from Inspector Controls to Block Controls.

Testing Instructions

  • Go to the editor.
  • Add Cover Block.
  • Add Cover image.
  • The Clear Media button is should now be present in Block Controls.

Screenshots or screencast

Before (Clear Media button in Inspector Controls):
cover-clear-media-inspector

After (Clear Media button in Block Controls):
clear-media-block

Copy link

github-actions bot commented Aug 20, 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.

Unlinked Accounts

The following contributors have not linked their GitHub and WordPress.org accounts: @rohitmathur-7.

Contributors, please read how to link your accounts to ensure your work is properly credited in WordPress releases.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Unlinked contributors: rohitmathur-7.

Co-authored-by: Mamaduka <mamaduka@git.wordpress.org>
Co-authored-by: jasmussen <joen@git.wordpress.org>
Co-authored-by: akasunil <sunil25393@git.wordpress.org>
Co-authored-by: richtabor <richtabor@git.wordpress.org>

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

@rohitmathur-7 rohitmathur-7 changed the title Move Clear media button from Inspector Controls to Block Controls Cover Block: Move Clear media button from Inspector Controls to Block Controls. Aug 20, 2024
@github-actions github-actions bot added the First-time Contributor Pull request opened by a first-time contributor to Gutenberg repository label Aug 20, 2024
Copy link

👋 Thanks for your first Pull Request and for helping build the future of Gutenberg and WordPress, @rohitmathur-7! 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.

@rohitmathur-7 rohitmathur-7 changed the title Cover Block: Move Clear media button from Inspector Controls to Block Controls. Cover Block: Move Clear Media button from Inspector Controls to Block Controls. Aug 20, 2024
@Mamaduka Mamaduka added [Type] Enhancement A suggestion for improvement. [Block] Cover Affects the Cover Block - used to display content laid over a background image labels Aug 20, 2024
@Mamaduka
Copy link
Member

Thanks, @rohitmathur-7!

Let's match other blocks like Featured Image that add control to the media replace dropdown. I'm also wondering if we should use "Reset" as a label instead of "Clear Media".

cc @jasmussen

Screenshot

CleanShot 2024-08-20 at 11 50 27

@jasmussen
Copy link
Contributor

Good opportunity to clean things up. A quick audit: Site logo has Reset in the dropdown:

Screenshot 2024-08-20 at 09 56 58

As does Featured Image:

Screenshot 2024-08-20 at 09 57 42

Image does not have it:

Screenshot 2024-08-20 at 09 57 07

Neither does Cover:

Screenshot 2024-08-20 at 09 57 19

It seems fine to add "Reset" in the dropdown for both Image and Cover, but I'd not call it "Clear Media", or add it to the block toolbar. Thank you for the contribution!

@Mamaduka
Copy link
Member

Thanks for the confirmation, @jasmussen!

@akasunil
Copy link
Member

Created PR #64669 to add "Reset" option on image block.

@rohitmathur-7
Copy link
Contributor Author

Hii @Mamaduka @jasmussen ,
Thanks for the feedback!

I have changed the name of Clear Media Button to Reset and added it in the dropdown.
Please review the PR and let me of if there are any other suggestions from your side.
Thanks.

reset-btn

@Mamaduka
Copy link
Member

Thank you, @rohitmathur-7!

It looks like the clears media when clear media button is clicked unit test for the cover block is failing.

Here's how to fix it:

  1. Let's move the test from "Inspector controls" to the "Block toolbar" block.
  2. The test will need some adjustments since the action is under the dropdown now and has a different label.

Here's what the updated test should look like:

test( 'clears media when clear media button clicked', async () => {
	await setup( {
		url: 'http://localhost/my-image.jpg',
	} );

	await selectBlock( 'Block: Cover' );
	expect(
		within( screen.getByLabelText( 'Block: Cover' ) ).getByRole(
			'img'
		)
	).toBeInTheDocument();

	await userEvent.click(
		screen.getByRole( 'button', { name: 'Replace' } )
	);
	await userEvent.click(
		screen.getByRole( 'menuitem', {
			name: 'Reset',
		} )
	);

	expect(
		within( screen.getByLabelText( 'Block: Cover' ) ).queryByRole(
			'img'
		)
	).not.toBeInTheDocument();
} );

@rohitmathur-7
Copy link
Contributor Author

Hii @Mamaduka ,
I have updated the code and moved it from Inspector Controls to Block Toolbar.
Can you please have a look now?
Thanks.

Copy link
Member

@Mamaduka Mamaduka left a comment

Choose a reason for hiding this comment

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

Thanks, @rohitmathur-7!

Everything looks good 👍

@Mamaduka Mamaduka merged commit 042f320 into WordPress:trunk Aug 24, 2024
60 checks passed
Copy link

Congratulations on your first merged pull request, @rohitmathur-7! We'd like to credit you for your contribution in the post announcing the next WordPress release, but we can't find a WordPress.org profile associated with your GitHub account. When you have a moment, visit the following URL and click "link your GitHub account" under "GitHub Username" to link your accounts:

https://profiles.wordpress.org/me/profile/edit/

And if you don't have a WordPress.org account, you can create one on this page:

https://login.wordpress.org/register

Kudos!

@github-actions github-actions bot added this to the Gutenberg 19.2 milestone Aug 24, 2024
bph pushed a commit to bph/gutenberg that referenced this pull request Aug 31, 2024
… Controls. (WordPress#64630)


Unlinked contributors: rohitmathur-7.

Co-authored-by: Mamaduka <mamaduka@git.wordpress.org>
Co-authored-by: jasmussen <joen@git.wordpress.org>
Co-authored-by: akasunil <sunil25393@git.wordpress.org>
Co-authored-by: richtabor <richtabor@git.wordpress.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Cover Affects the Cover Block - used to display content laid over a background image First-time Contributor Pull request opened by a first-time contributor to Gutenberg repository [Type] Enhancement A suggestion for improvement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cover Block: Move Clear Media button from Inspector Controls to Block Controls.
4 participants