WordPress / gutenberg

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

Vertical alignment tools: Show help text explaining they require height to work #62778

Open jasmussen opened 1 week ago

jasmussen commented 1 week ago

The Stack block has vertical alignment tools in its block toolbar:

stack block toolbar

But these options—middle, bottom, space-between—only work if the Stack itself has a height that is taller than the contents inside:

stack with height

This can be confusing for anyone looking at these tools, they might think the vertical alignment tools affect the containers presence in a parent, as opposed to what it actually does, affect the items inside itself. Either way, unless your Stack block has a height, it will be confusing to try those options and see no change.

Suggestion: we add a separator and some help text to the dropdown:

Help text reads: Vertical alignments only show up if the container also has a height applied.
jasmussen commented 1 week ago

CC: @WordPress/gutenberg-design @mtias

t-hamano commented 1 week ago

Another idea would be to replace it with DropdownMenu V2.

This component allows us to add a prefix icon and help text to each menu item.

https://wordpress.github.io/gutenberg/?path=/story/components-experimental-dropdownmenu-v2--default

image

There seems to be a discussion about migrating to DropdownMenu V2 in #61094.

jameskoster commented 1 week ago

I suppose we can't conditionally show the notice because height could be added by custom css? It's a bit of a shame to pollute the UI in irrelevant situations.

"Show up" reads a little strange to me. I wonder if that should be something like "Vertical alignments will only work if the..."

jasmussen commented 1 week ago

I suppose we can't conditionally show the notice because height could be added by custom css? It's a bit of a shame to pollute the UI in irrelevant situations.

That was a first instinct too, but I also don't see a way this could work.

There are also cases where the height can be dynamic. Imagine one of the child blocks has a block connection to a dynamic external source, so the height changes on every reload.

DropdownMenu V2 could work too, though we'd still need to decide what help text to show, and where. I.e. 3 of 4 options would all be affected by this, it feel duplicative to write it out for each.

jasmussen commented 1 week ago

"Show up" reads a little strange to me. I wonder if that should be something like "Vertical alignments will only work if the..."

Oh yes I should've clarified, I'd very much like suggestions on the entire copy. It's not reading that well to me, what I suggested. Yours is an improvement, but just want to invite full alternatives too.

richtabor commented 1 week ago

Either way, unless your Stack block has a height, it will be confusing to try those options and see no change.

It's not only when a stack has a height, it also when the height in influenced by surrounding flex elements.

I'm not certain this is necessary, nor quite helpful, really.