WordPress / gutenberg

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

Social Icons: Change the block placeholder and use a button #60202

Open afercia opened 7 months ago

afercia commented 7 months ago

Description

Splitting this out from https://github.com/WordPress/gutenberg/issues/56259 and https://github.com/WordPress/gutenberg/pull/59303#issuecomment-2020213013

Potentially solves also https://github.com/WordPress/gutenberg/issues/60120

Cc @getdave @WordPress/gutenberg-design

Currently, the Social Icons block shows two placeholders:

When the block is selected

The block shows a 'Click plus to add' text and a 'plus' icon button at the right edge of the block, labeled 'Add block'. This button is the standard 'block list appender toggle' used for other blocks as well. Screenshot:

Screenshot 2024-03-26 at 10 37 40

This doesn't seem to be ideal for a few reasons:

When the block is not selected

The placeholder changes to 3 colored squares. Screenshot:

Screenshot 2024-03-26 at 09 47 30

This doesn't seem to be ideal for a few reasons:

Screenshot 2024-03-26 at 13 21 36

Proposal

Quoting from https://github.com/WordPress/gutenberg/issues/56259

I'd totally agree the placeholder should be a button to 'add' social links. Other blocks already use similar placeholders, for example Row, Stack, Grid. They use a rectangular button with a plus icon. I'd like to propose to use the same kind of button and sytling, just making the button rounded in this case.

Very rough screenshots:

The new 'Add' button should show when first inserting the empty block and always shown at the end when the blosk is selected and being edited:

Screenshot 2024-03-26 at 13 39 49 2

The button should not be shown when the block is not selected or not being edited:

Screenshot 2024-03-26 at 13 53 29

Consider to make the button label visible (spacing to be improved):

Screenshot 2024-03-26 at 13 39 49 2 2

Making the button available when editing would also solve the keyboard operability reported at https://github.com/WordPress/gutenberg/issues/60120

Step-by-step reproduction instructions

N/A

Screenshots, screen recording, code snippet

No response

Environment info

No response

Please confirm that you have searched existing issues in the repo.

Yes

Please confirm that you have tested with all plugins deactivated except Gutenberg.

Yes

t-hamano commented 7 months ago

Thank you for your suggestion.

The new 'Add' button should show when first inserting the empty block and always shown at the end when the block is selected and being edited:

The two inserter buttons for inserting blocks feel a little strange to me since they have the same role.

The approach I suggest is to automatically insert one Social Link block when you insert a Social Links block:

image

The only block that can be included in a Social Links block is a Social Link block, and its initial behavior is the same as that of a Buttons block:

image

And if no Social Icon block exists, it will only show the default inserter:

image

This is also similar to the current Buttons block behavior:

image

Are there any accessibility concerns with this approach? Whichever direction we go in, I feel it's better to unify the behavior of the social icon block and the button block.

t-hamano commented 7 months ago

As another example, the specifications for the navigation block are as follows:

When a block is not selected: A dot border is displayed.

image

When a block is selected: A large inserter button is displayed.

image

richtabor commented 7 months ago

I think this is along what I was suggesting previously, by always having an icon inserter to the right of the icons, when interacting with the block.

https://github.com/WordPress/gutenberg/issues/56259#issuecomment-1841861841

afercia commented 7 months ago

The two inserter buttons for inserting blocks feel a little strange

I agree. I'm unsure whether the black 'plus' ineerter should be kept. It is worth noting that right now it is not operable with a keyboard after a first social link has been added. See https://github.com/WordPress/gutenberg/issues/60120 This block is not operable with a keyboard. As such, either we fix the inserter or we should replace it.

afercia commented 1 month ago

https://github.com/WordPress/gutenberg/pull/64877 solved some parts of this issue.

Seems to me the only thing left is this:

placeholder

When there are no social links inserted yet and the block is not selected, the placeholder still shows a few colored boxes. Im not sure this is correct. The placeholder shouldn't 'preview' or attempt to provide a visual representation of the expected visuals when there's no links added yet. Also, I'm not sure thosee 3 colored boxes are consistent with other blocks and I'm not sure they help users in any way.

In this state, with no links added yet and no selection, I'd just suggest to just show the block appender button.