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

Improve parent block selector button UI #23800

Closed

Conversation

ZebulanStanphill
Copy link
Member

@ZebulanStanphill ZebulanStanphill commented Jul 8, 2020

Description

Closes #23766.

Checklist:

  • My code is tested.
  • My code follows the WordPress code style.
  • My code follows the accessibility standards.
  • My code has proper inline documentation.
  • I've included developer documentation if appropriate.
  • I've updated all React Native files affected by any refactorings/renamings in this PR.

@ZebulanStanphill ZebulanStanphill added [Type] Enhancement A suggestion for improvement. General Interface Parts of the UI which don't fall neatly under other labels. Needs Design Feedback Needs general design feedback. Needs Technical Feedback Needs testing from a developer perspective. [Package] Block editor /packages/block-editor labels Jul 8, 2020
@github-actions
Copy link

github-actions bot commented Jul 8, 2020

Size Change: -318 B (0%)

Total Size: 1.19 MB

Filename Size Change
build/block-editor/index.js 130 kB -141 B (0%)
build/block-editor/style-rtl.css 10.9 kB -71 B (0%)
build/block-editor/style.css 10.9 kB -71 B (0%)
build/components/style-rtl.css 15.5 kB -18 B (0%)
build/components/style.css 15.5 kB -17 B (0%)
ℹ️ View Unchanged
Filename Size Change
build/a11y/index.js 1.14 kB 0 B
build/annotations/index.js 3.52 kB 0 B
build/api-fetch/index.js 3.35 kB 0 B
build/autop/index.js 2.72 kB 0 B
build/blob/index.js 667 B 0 B
build/block-directory/index.js 8.56 kB 0 B
build/block-directory/style-rtl.css 943 B 0 B
build/block-directory/style.css 942 B 0 B
build/block-library/editor-rtl.css 8.65 kB 0 B
build/block-library/editor.css 8.65 kB 0 B
build/block-library/index.js 145 kB 0 B
build/block-library/style-rtl.css 7.7 kB 0 B
build/block-library/style.css 7.7 kB 0 B
build/block-library/theme-rtl.css 741 B 0 B
build/block-library/theme.css 741 B 0 B
build/block-serialization-default-parser/index.js 1.78 kB 0 B
build/block-serialization-spec-parser/index.js 3.1 kB 0 B
build/blocks/index.js 47.6 kB 0 B
build/components/index.js 169 kB 0 B
build/compose/index.js 9.63 kB 0 B
build/core-data/index.js 12 kB 0 B
build/data-controls/index.js 685 B 0 B
build/data/index.js 8.63 kB 0 B
build/date/index.js 31.9 kB 0 B
build/deprecated/index.js 772 B 0 B
build/dom-ready/index.js 568 B 0 B
build/dom/index.js 4.42 kB 0 B
build/edit-navigation/index.js 10.6 kB 0 B
build/edit-navigation/style-rtl.css 868 B 0 B
build/edit-navigation/style.css 871 B 0 B
build/edit-post/index.js 306 kB 0 B
build/edit-post/style-rtl.css 6.29 kB 0 B
build/edit-post/style.css 6.28 kB 0 B
build/edit-site/index.js 21.3 kB 0 B
build/edit-site/style-rtl.css 3.8 kB 0 B
build/edit-site/style.css 3.81 kB 0 B
build/edit-widgets/index.js 21.2 kB 0 B
build/edit-widgets/style-rtl.css 3.03 kB 0 B
build/edit-widgets/style.css 3.03 kB 0 B
build/editor/editor-styles-rtl.css 480 B 0 B
build/editor/editor-styles.css 482 B 0 B
build/editor/index.js 45.5 kB 0 B
build/editor/style-rtl.css 3.85 kB 0 B
build/editor/style.css 3.84 kB 0 B
build/element/index.js 4.45 kB 0 B
build/escape-html/index.js 734 B 0 B
build/format-library/index.js 7.49 kB 0 B
build/format-library/style-rtl.css 547 B 0 B
build/format-library/style.css 548 B 0 B
build/hooks/index.js 1.74 kB 0 B
build/html-entities/index.js 622 B 0 B
build/i18n/index.js 3.54 kB 0 B
build/is-shallow-equal/index.js 710 B 0 B
build/keyboard-shortcuts/index.js 2.39 kB 0 B
build/keycodes/index.js 1.85 kB 0 B
build/list-reusable-blocks/index.js 3.02 kB 0 B
build/list-reusable-blocks/style-rtl.css 476 B 0 B
build/list-reusable-blocks/style.css 476 B 0 B
build/media-utils/index.js 5.12 kB 0 B
build/notices/index.js 1.69 kB 0 B
build/nux/index.js 3.27 kB 0 B
build/nux/style-rtl.css 671 B 0 B
build/nux/style.css 668 B 0 B
build/plugins/index.js 2.44 kB 0 B
build/primitives/index.js 1.34 kB 0 B
build/priority-queue/index.js 790 B 0 B
build/redux-routine/index.js 2.85 kB 0 B
build/rich-text/index.js 13 kB 0 B
build/server-side-render/index.js 2.6 kB 0 B
build/shortcode/index.js 1.69 kB 0 B
build/token-list/index.js 1.24 kB 0 B
build/url/index.js 4.06 kB 0 B
build/viewport/index.js 1.75 kB 0 B
build/warning/index.js 1.13 kB 0 B
build/wordcount/index.js 1.17 kB 0 B

compressed-size-action

@ZebulanStanphill ZebulanStanphill force-pushed the update/parent-block-selector-button-ui branch 2 times, most recently from f70b126 to d167f30 Compare July 9, 2020 03:47
@ZebulanStanphill
Copy link
Member Author

ZebulanStanphill commented Jul 9, 2020

Here's what I've got so far:
image

I was planning to add a gap between the parent-selector and the rest of the toolbar:

image

But adding that extra space is a lot harder than it may seem. The outermost borders and background color are provided by the block-editor-block-contextual-toolbar that contains both the parent-selector button as well as all the other toolbar buttons. To style it like the mockup requires a lot of complex style overriding.

Perhaps it is okay to not have the gap?

It's worth noting that something like a thicker border would be a lot easier to do, albeit a bit non-standard. Then again, separating the parent-selector with a gap even though it's technically still part of the toolbar is also non-standard.

image

So what do you think I should do? Personally, I'm okay with the current design in this PR.

@mapk
Copy link
Contributor

mapk commented Jul 9, 2020

This is currently what I'm seeing right now:

Screen Shot 2020-07-09 at 1 55 16 PM

The parent icon does not have a right border. Looking at your mockups though, I still prefer the detached parent icon. The disconnection of the two help identify it as something tangentially related to the selected block, and not as part of the selected block itself.

@ZebulanStanphill
Copy link
Member Author

Well, I'm gonna need help to get it looking like the mockups.

@ZebulanStanphill ZebulanStanphill force-pushed the update/parent-block-selector-button-ui branch from d167f30 to 7f02e92 Compare July 10, 2020 01:35
@ZebulanStanphill
Copy link
Member Author

Also, I rebased and tested the branch myself and there's no missing border for me. I've tested on the Twenty Twenty theme, though I don't think the theme should make any difference. Could you try again now that the branch has been rebased?

@mapk
Copy link
Contributor

mapk commented Jul 10, 2020

I'm still seeing no border in Chrome and Firefox. 🤔

Screen Shot 2020-07-10 at 10 08 08 AM

@shaunandrews
Copy link
Contributor

I dig this, though I think having the space between the parent button and the block toolbar is needed — otherwise its not totally obvious what block is currently selected; Its strange to have two block icons in (visually) single toolbar.

I think you could try adding some margin to the toolbar, and then absolute position the parent button, similar to how it works currently.

@ZebulanStanphill ZebulanStanphill force-pushed the update/parent-block-selector-button-ui branch from 7f02e92 to b318b49 Compare July 13, 2020 19:59
@ZebulanStanphill
Copy link
Member Author

Good idea, @shaunandrews! I did just that, and here's what it looks like now:

image

The CSS is a bit more complicated now, but it's still better than what's in master, so I think this will be good to merge if everyone likes how this latest iteration looks/functions.

* @param {Function} [props.onChange=noop] Callback function.
*/
export function useDebouncedShowMovers( {
export function useDebouncedActivateCallbacks( {
Copy link
Member Author

Choose a reason for hiding this comment

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

This is now only being used for the block outline shown when the block icon is hovered. I could follow up with another PR to remove the debouncing entirely, if desired.

draganescu
draganescu previously approved these changes Jul 14, 2020
Copy link
Contributor

@draganescu draganescu left a comment

Choose a reason for hiding this comment

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

I have tested this and the code LGTM 🚢

@mtias
Copy link
Member

mtias commented Jul 14, 2020

Thanks for exploring this. I have to say the proposal gives me a lot of pause as it turns something that was convenient but not primary into the most prominent aspect of the block toolbar, visible at all times. Considering nested blocks are going to become more and more the norm, I think we need to be more careful here:

  • It's harder to see at a glance what block you are working with.
  • The drag / move / transform is pushed into a secondary role.
  • Significantly increases the horizontal space the toolbar takes with an action that is not primary to the current block. (More problematic the narrower the context becomes.)
  • Select mode doesn't match anymore (the start of the current block type name differs between the two).
  • Other cases with child blocks (like horizontal ones: social icons, buttons, etc) become more confusing in terms of alignment:

image

And we get out of bounds much more easily:

image

Given this has the potential of significantly changing the experience by introducing a permanently visible item, I think we should wait a bit more and continue to explore possible solutions.

@draganescu draganescu dismissed their stale review July 14, 2020 11:49

Needs more design exploration

@ZebulanStanphill
Copy link
Member Author

The out-of-bounds thing isn't supposed to happen. I think that issue happens on master too? In my testing, resizing the viewport causes the toolbar to get shifted over to not go out of bounds.

The other points are definitely valid, though. Feel free to post suggestions in #23766.

Other cases with child blocks (like horizontal ones: social icons, buttons, etc) become more confusing in terms of alignment

The iteration without the gap between the parent selector and the rest of the toolbar doesn't have this problem, but it still has all the other issues mentioned, unfortunately.

@ZebulanStanphill
Copy link
Member Author

I've been thinking about this for a while. I think a proper solution needs to appear as part of the toolbar (because it is), rather than appear detached from it. And I definitely still think there's value in making the parent-selector more prominent. There's an increasing number of cases where users will want to quickly access the controls of the current parent:

  • Get to the Group or Column from the blocks nested in them.
  • Get to the Columns from a Column.
  • Eventually, getting to the Quote block from the Paragraph blocks nested inside it.
  • If we go with an Accordions block implementation that groups multiple individual accordion items so that opening one closes the other, we need to make it easy to access the accordion group block, which is where most of the style controls will probably belong.

Always showing the parent selector when available also makes it more obvious that you're inside a nested block in the first place. This is important info to know when dealing with complex layouts or newly-installed blocks.

The problem with my initial design in this PR is that the difference/relation between the two icons is not immediately clear. What's the difference between the two? I think part of the issue stems from the current block icon button being rather "loaded": it visually conveys state (which block am I editing?) while also serving as the button to open the transforms/styles dropdown. This is questionable from an a11y (and just general usability) perspective. Throwing in another button that uses a block icon is difficult because now you have two buttons with very different actions but a similar appearance.

A full solution would probably involve splitting the current block icon button into two separate things: a simple block icon (with an aria-label containing the block name) and a dedicated style/transform button. That would be the best solution, a11y-wise. But that would lengthen the toolbar, running into another longstanding issue with the block toolbar design: namely that there simply isn't enough room to show all the controls properly.

I've noticed that we keep running into this same issue over and over and over again. The drag handle shouldn't be invisible like it is now, but making it visible would lengthen the toolbar. For ideal a11y, the movers shouldn't be stacked, but changing that would lengthen the toolbar. It would be good to have a "visible text labels" option, but that would be really difficult to handle because of how much it would lengthen the toolbar.

But while solving these issues is essential in the long run, if you ask me... it's also way outside the scope of this issue. So either we have to solve the major problems with the block toolbar design first and leave this on hold, or this PR needs to come up with something else that is at least better than what we have in master right now.

With that in mind, here's an idea I've been sitting on for a while:
image

The chevron-style shape is intended to make it look a bit like a sort of breadcrumb, which helps to clarify the relation between the two icons. I'm not entirely sure how to actually pull this off; I guess it would involve an absolutely-positioned ::after pseudo-element with a border on two adjacent sides that's been rotated 45 degrees.

What do you think? Is this design "good enough"?

@ZebulanStanphill ZebulanStanphill force-pushed the update/parent-block-selector-button-ui branch from b318b49 to ba3866b Compare August 12, 2020 03:04
@ZebulanStanphill
Copy link
Member Author

I've removed the gap between the parent-selector-button and the rest of the toolbar. We ought to be avoiding special-case styling like that.

Here's what it looks like after rebasing the PR to include all the latest UI changes in master:
image

The inconsistent usage of block icons to mean two different things is still a problem. I'm going to post some ideas about how to move forward in #23766, but for now I wanted to go ahead and push an update to this PR to prevent it from getting too stale.

@ZebulanStanphill ZebulanStanphill force-pushed the update/parent-block-selector-button-ui branch 2 times, most recently from 265c149 to 012fda8 Compare September 25, 2020 19:27
@ZebulanStanphill
Copy link
Member Author

Following my latest idea in #23766, I've once again changed how the "Select parent" option is presented. This time, I've moved it out of the main part of the block toolbar and into the "More options" menu.

image

I believe this approach solves every problem with prior designs except, perhaps, the issue of discoverability. Please let me know what you think about this design in #23766.

@ZebulanStanphill ZebulanStanphill force-pushed the update/parent-block-selector-button-ui branch from 012fda8 to c414501 Compare September 25, 2020 19:50
@ZebulanStanphill ZebulanStanphill removed the [Status] Blocked Used to indicate that a current effort isn't able to move forward label Sep 27, 2020
@ZebulanStanphill ZebulanStanphill force-pushed the update/parent-block-selector-button-ui branch 2 times, most recently from 69af0b9 to 80f7032 Compare October 12, 2020 22:57
@ZebulanStanphill
Copy link
Member Author

Per @mtias' feedback, I've added the parent block's icon to the menu item:

image

@mtias
Copy link
Member

mtias commented Jan 28, 2021

I'm looping back on this one. Thanks for all the iterations and tweaks so far, much appreciated!

I'm coming around to the fact perhaps we need slightly different treatments for some of these contexts. For example, the initial design proposed here matches well for this use case: #28522. Likely also for Gallery. The case of social icons and buttons is a bit tricky since the container is really there to facilitate creation of multiple items, so for that one I feel we need to work on the absorb toolbar part and make it seem like there's no parent block at all.

Unsure if we should be applying the same treatment to parents that are indifferent to its children (Cover, Group, Columns, Template Parts). So my current thinking is to split the work in three:

  • Use the initial design for some blocks. (Figure out how to do the opt in.)
  • Add the ellipsis menu action regardless as it seems useful in general. (For example, we might want to never show two block type icons on mobile for spacing, so the ellipsis menu would be the main way to go up in that case.)
  • Work on the absorb toolbar design.

@mtias
Copy link
Member

mtias commented Jan 28, 2021

In terms of inner blocks that would leave us with three configurations:

And also include the “select parent” in the ellipsis menu from this PR for mobile and redundancy.

@ZebulanStanphill
Copy link
Member Author

ZebulanStanphill commented Feb 9, 2021

@mtias With #28598 merged, do you think it still makes sense to add an ellipsis menu option to select the parent block?

Base automatically changed from master to trunk March 1, 2021 15:43
@mtias
Copy link
Member

mtias commented Jun 25, 2021

@ZebulanStanphill sorry missed this comment. I think in mobile the situation is still not great and the ellipsis button could be useful, but it's definitely less pressing than before with all the latest tools (parent selector, list view, etc). Another place from where I think it should be possible to select a parent container is the sidebar inspector, particularly on blocks that are semantically tied (buttons:button, navigation:navigation-link, social-icons:social-icon).

@ZebulanStanphill
Copy link
Member Author

I forgot this PR was still open. Closing, since #40105 superseded it.

@ZebulanStanphill ZebulanStanphill deleted the update/parent-block-selector-button-ui branch May 10, 2022 13:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
General Interface Parts of the UI which don't fall neatly under other labels. Needs Design Feedback Needs general design feedback. Needs Technical Feedback Needs testing from a developer perspective. [Package] Block editor /packages/block-editor [Type] Enhancement A suggestion for improvement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Improve usability of parent block selector button
5 participants