WordPress / gutenberg

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

Devise a mechanism by which the block options menu can scale more elegantly #49271

Open jameskoster opened 1 year ago

jameskoster commented 1 year ago

What problem does this address?

We've added a lot of items to the block options menu. It's become a bit unwieldy and it's not uncommon to encounter a scrollbar which buries frequent actions:

https://user-images.githubusercontent.com/846565/226925531-9cabb6d1-49f9-4332-95ab-b2d4efc7fada.mp4

What is your proposed solution?

A flyout has been suggested in https://github.com/WordPress/gutenberg/issues/47464. We can theoretically apply that to some of the actions in this menu to reduce its initial footprint and better organise actions.

Screenshot 2023-04-04 at 10 19 13

The flyout is only one approach, how else can we address this?

richtabor commented 1 year ago

Related in part to https://github.com/WordPress/gutenberg/issues/42203.

A couple top-of-mind thoughts:

jameskoster commented 1 year ago

I agree on getting rid of the block name in the remove action. It's very noisy if you selected something with a long name like a template part or reusable block. "Delete" makes sense to me.

"Move to" seems the least important one here.

I know some folks use this a lot so curious to hear more on this point.

I like the idea of having the most important/always on every block options into its own MenuGroup

This would align a bit with the block transform menu so could be a good change.

jameskoster commented 1 year ago

A small update on this one:

Screenshot 2023-03-30 at 15 27 14
richtabor commented 1 year ago

Do you think we need "selection" in "Group selection" — I'm thinking not. And where would "Edit as HTML" go?

richtabor commented 1 year ago

My one hesitation is moving Insert before/after into a flyout. It makes sense on paper, but subjectively I use "Insert before" likely more often than another other item on the list.

richtabor commented 1 year ago

Also, the separator would be $gray-900, right?

richtabor commented 1 year ago

We also have "Select parent block (blockName)" to account for. I'm thinking it shouldn't displace the other items in the common actions. Perhaps append to the end of the common actions?

CleanShot 2023-03-31 at 22 04 11
alexstine commented 1 year ago

Left some feedback on the linked PR.

I am not sure this discussion needs to happen over delete blocks or the entire toolbar itself. Likely the toolbar. That way we can provide some type of description on the toolbar to let users know the controls apply to the selected blocks. Might be good for a follow-up PR since all of this is being discussed currently.

jameskoster commented 1 year ago

We also have "Select parent block (blockName)" to account for

Do we still need this? The paren't selector seems like a more convenient affordance, but I'm not familiar with the history.

I use "Insert before" likely more often than another other item on the list

No big deal to keep these top level:

Screenshot 2023-04-03 at 14 08 59

Group 1

Group 2

richtabor commented 1 year ago

I'd adapt Group 2 as follows:

richtabor commented 1 year ago

It makes sense to keep delete in the last group at the end of the menu for quick access with up arrow key.

We should probably have a divide between it and others then. I don't want it to get lost (though I don't know that three groups is really necessary).

What if it was prioritized over Add before/after, like this:

alexstine commented 1 year ago

Even in native OS menus such as Windows, delete option is always near the bottom.

  1. Open file explorer.
  2. Right click an item.
  3. Notice how bottom to top goes Properties, Delete, etc.

Delete is a destructive action. Nice to have it at the end.

richtabor commented 1 year ago

It's not always last, on MacOS at least — but as long as it's not lost, I'm good. :)

richtabor commented 1 year ago

In all, we're a bit in the weeds—but forward progress; love it.

The big blocker here is the flyout type component. @alexstine what are your thoughts on flyouts (or submenus) in this use case. Do you have examples, or other libraries, that leverage accessible submenus in UI well?

Like the Radix DropdownMenu component for example.

richtabor commented 1 year ago

Do we still need this? The paren't selector seems like a more convenient affordance, but I'm not familiar with the history.

I don't think we do.

alexstine commented 1 year ago

I am not familiar with any 3rd party libraries that have out of the box accessible components. Most React/Vue libraries are junk for accessibility. Any reason we're not going to develop this in wordpress/components?

Happy to check any examples but I will set expectations now.

Thanks.

richtabor commented 1 year ago

Any reason we're not going to develop this in wordpress/components?

Likely will, though I would like to start off with good examples to work from if possible.

alexstine commented 1 year ago

@richtabor I am having a really hard time coming up with any ARIA specifications for flyout menus. If it helps, the flyout menu for Google Drive is perfectly accessible. Other than that, I think we'll have to just see what works. I am kind of interested to see if there are any accessible examples out there but I am coming up empty.

@joedolson You know of any good material on this?

Thanks.

jameskoster commented 1 year ago

I've updated the design in the OP based on discussion, and will mark comments as outdated. Agree the design is in a decent place as a starting point.

The one detail missing is whether or not we still need the Select parent action. I think it predates both List View and the dedicated parent selector affordance, which both feel like more convenient ways to select the direct ancestor, hence the removal. What do y'all think?

alexstine commented 1 year ago

@jameskoster Where is the dedicated select parent located?

ciampo commented 1 year ago

Any reason we're not going to develop this in wordpress/components?

We are indeed looking into adding support for nested dropdown menus, but as @richtabor also explained, it's good to start exploring our usecases and let that help us to make the right decisions.

It's very likely that we'll resort to a third party library, since this pattern is quite complex and difficult to get right, and there's no need for us to reinvent the wheel. Hopefully we'll find a good solution that is accessible, fits our needs, and at the same time works with all the constraints of the editor (the biggest one that comes to mind is syncing position updates across the iframe).

I hope we'll be able to share updates within the upcoming weeks.

alexstine commented 1 year ago

Oh, the iFrame. That will be interesting for sure. Still having a really hard time getting basic functionality to work in it across all screen readers. See #47767 for more context. I urge us all to really take our time in testing. I am a screen reader user and not testing on both platforms came back to haunt me there.

jameskoster commented 1 year ago

@jameskoster Where is the dedicated select parent located?

@alexstine it's the first item in the block toolbar, titled 'Select [block name]'.

alexstine commented 1 year ago

@jameskoster Awesome. No need to keep it in the more menu then.

richtabor commented 1 year ago

We are indeed looking into adding support for nested dropdown menus

Here's another use case for supporting nested dropdowns: https://github.com/WordPress/gutenberg/issues/40208

richtabor commented 1 year ago

@ciampo do we have/need an issue separate for the nested dropdown? And is there an update on that front perhaps? Thanks!

ciampo commented 1 year ago

@ciampo do we have/need an issue separate for the nested dropdown?

We didn't, but I just created one: https://github.com/WordPress/gutenberg/issues/50459

And is there an update on that front perhaps? Thanks!

I plan on releasing a very experimental, initial version of the component in the next days. It will still need tweaking and lots of testing in the editor, but hopefully we'll get there quickly enough

richtabor commented 1 year ago

I plan on releasing a very experimental, initial version of the component in the next days. It will still need tweaking and lots of testing in the editor, but hopefully we'll get there quickly enough

Very cool!