WordPress / gutenberg

The Block Editor project for WordPress and beyond. Plugin is available from the official repository.
https://wordpress.org/gutenberg/
Other
10.49k stars 4.18k forks source link

`MenuRadioItem`: add an optional checked prefix #66666

Closed ramonjd closed 9 hours ago

ramonjd commented 1 day ago

What?

Add an optional checkedPrefix prop to MenuRadioItem to customize the checked icon.

Why?

The dot may not be desirable in some designs.

How?

Added a checkedPrefix react node prop to the component.

prefix seemed to imply permanence, so I added checked to the front.

Testing Instructions

Fire up story book npm run storybook:dev and preview it here:

http://localhost:50240/?path=/story/components-experimental-menu--with-radios

Testing Instructions for Keyboard

Screenshots or screencast

https://github.com/user-attachments/assets/97cb2e06-a774-431e-be10-5e8834566eea

github-actions[bot] commented 1 day ago

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: ramonjd <ramonopoly@git.wordpress.org>
Co-authored-by: jameskoster <jameskoster@git.wordpress.org>

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

jameskoster commented 19 hours ago

I think the purpose of MenuRadioItem and MenuCheckboxItem is to be opinionated about the design and tie the visuals to underlying semantics. The dot communicates single-select while the check indicates multi-select or toggle-ability. Radios probably shouldn't display checkmarks else we introduce inconsistencies and confusion.

This may have been my fault by sharing a misleading design in https://github.com/WordPress/gutenberg/pull/65619. Apologies!

ramonjd commented 9 hours ago

Thanks! Worth a shot 😄 I'll close for now until there's a case for it.