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

Add initial quick inserter #22789

Merged
merged 19 commits into from
Jun 24, 2020
Merged

Add initial quick inserter #22789

merged 19 commits into from
Jun 24, 2020

Conversation

youknowriad
Copy link
Contributor

@youknowriad youknowriad commented Jun 1, 2020

related #21080

This PR starts implementing the quick inserter. It's early implementation and the task has proven to be harder than expected for two reasons:

  • The inserter is a complex UI with a lot of logic and interactions
  • The quick inserter specs are still early and not very precise yet, I'm thinking iterating on this PR will help us clear things out.

I'm still trying to figure out what would be the MVP to ship this.

Capture d’écran 2020-06-01 à 12 17 48 PM

@youknowriad youknowriad added [Type] Enhancement A suggestion for improvement. [Feature] Inserter The main way to insert blocks using the + button in the editing interface labels Jun 1, 2020
@youknowriad youknowriad self-assigned this Jun 1, 2020
@github-actions
Copy link

github-actions bot commented Jun 1, 2020

Size Change: +1.22 kB (0%)

Total Size: 1.13 MB

Filename Size Change
build/block-directory/index.js 7.37 kB -1 B
build/block-editor/index.js 108 kB +712 B (0%)
build/block-editor/style-rtl.css 10.9 kB +195 B (1%)
build/block-editor/style.css 10.9 kB +192 B (1%)
build/block-library/index.js 129 kB -1 B
build/blocks/index.js 48.2 kB -2 B (0%)
build/components/index.js 197 kB +7 B (0%)
build/core-data/index.js 11.4 kB +1 B
build/data/index.js 8.44 kB +2 B (0%)
build/edit-navigation/index.js 9.87 kB +1 B
build/edit-post/index.js 303 kB +75 B (0%)
build/edit-site/index.js 16.6 kB +5 B (0%)
build/editor/index.js 44.9 kB +27 B (0%)
build/rich-text/index.js 14 kB +1 B
build/token-list/index.js 1.28 kB +2 B (0%)
ℹ️ View Unchanged
Filename Size Change
build/a11y/index.js 1.14 kB 0 B
build/annotations/index.js 3.62 kB 0 B
build/api-fetch/index.js 3.4 kB 0 B
build/autop/index.js 2.82 kB 0 B
build/blob/index.js 620 B 0 B
build/block-directory/style-rtl.css 941 B 0 B
build/block-directory/style.css 942 B 0 B
build/block-library/editor-rtl.css 7.59 kB 0 B
build/block-library/editor.css 7.6 kB 0 B
build/block-library/style-rtl.css 8.04 kB 0 B
build/block-library/style.css 8.04 kB 0 B
build/block-library/theme-rtl.css 730 B 0 B
build/block-library/theme.css 732 B 0 B
build/block-serialization-default-parser/index.js 1.88 kB 0 B
build/block-serialization-spec-parser/index.js 3.1 kB 0 B
build/components/style-rtl.css 15.8 kB 0 B
build/components/style.css 15.8 kB 0 B
build/compose/index.js 9.62 kB 0 B
build/data-controls/index.js 1.29 kB 0 B
build/date/index.js 5.47 kB 0 B
build/deprecated/index.js 772 B 0 B
build/dom-ready/index.js 569 B 0 B
build/dom/index.js 3.19 kB 0 B
build/edit-navigation/style-rtl.css 1.02 kB 0 B
build/edit-navigation/style.css 1.02 kB 0 B
build/edit-post/style-rtl.css 5.5 kB 0 B
build/edit-post/style.css 5.5 kB 0 B
build/edit-site/style-rtl.css 3.02 kB 0 B
build/edit-site/style.css 3.02 kB 0 B
build/edit-widgets/index.js 9.32 kB 0 B
build/edit-widgets/style-rtl.css 2.42 kB 0 B
build/edit-widgets/style.css 2.42 kB 0 B
build/editor/editor-styles-rtl.css 537 B 0 B
build/editor/editor-styles.css 539 B 0 B
build/editor/style-rtl.css 3.81 kB 0 B
build/editor/style.css 3.81 kB 0 B
build/element/index.js 4.65 kB 0 B
build/escape-html/index.js 733 B 0 B
build/format-library/index.js 7.73 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 2.13 kB 0 B
build/html-entities/index.js 622 B 0 B
build/i18n/index.js 3.56 kB 0 B
build/is-shallow-equal/index.js 710 B 0 B
build/keyboard-shortcuts/index.js 2.51 kB 0 B
build/keycodes/index.js 1.94 kB 0 B
build/list-reusable-blocks/index.js 3.13 kB 0 B
build/list-reusable-blocks/style-rtl.css 450 B 0 B
build/list-reusable-blocks/style.css 451 B 0 B
build/media-utils/index.js 5.29 kB 0 B
build/notices/index.js 1.79 kB 0 B
build/nux/index.js 3.4 kB 0 B
build/nux/style-rtl.css 663 B 0 B
build/nux/style.css 660 B 0 B
build/plugins/index.js 2.56 kB 0 B
build/primitives/index.js 1.5 kB 0 B
build/priority-queue/index.js 789 B 0 B
build/redux-routine/index.js 2.85 kB 0 B
build/server-side-render/index.js 2.68 kB 0 B
build/shortcode/index.js 1.7 kB 0 B
build/url/index.js 4.06 kB 0 B
build/viewport/index.js 1.85 kB 0 B
build/warning/index.js 1.14 kB 0 B
build/wordcount/index.js 1.17 kB 0 B

compressed-size-action

@enriquesanchez
Copy link
Contributor

Hi @youknowriad! 👋

Took it for a test on Firefox. I found a placement bug when the inserter is near the top of the document:

Screen Shot 2020-06-02 at 17 59 12

The inserter looked good when invoked from a lower place:

Screen Shot 2020-06-02 at 18 04 03

Did a quick test with only keyboard and I did not find any issues.

@youknowriad
Copy link
Contributor Author

Thanks @enriquesanchez yes, it seems the Popover component doesn't refresh its size when the size of the content changes (start searching), I'll try to debug it.

@jasmussen
Copy link
Contributor

Amazing work, Riad. I'm happy to get an initial version of this in, but I think we need to try and move a little closer to the mockups.

The initial state:

Screenshot 2020-06-03 at 10 06 18

The mockup:

Screenshot 2020-06-03 at 10 06 49

  • If we can default to opening up and right from the plus, this is a good start. I'm aware that there are situations where it will open in other directions, that's fine — but we should have a good default.
  • We need to unblock the popover PR so we avoid using the block UI for this popover.

Search:

Screenshot 2020-06-03 at 10 09 58

I don't know how possible this is, can we be smarter about the height of the inserter? It was cropped by the viewport and I had to scroll to see the whole thing:

Screenshot 2020-06-03 at 10 10 05

I imagine that this is very technically challenging, so as an alternative, we should look into a max-height. As it is, this is very tall compared to the mockup:

Screenshot 2020-06-03 at 10 12 14

Some things that should help make it smaller:

  • Gray separator between blocks and patterns, that way we can also remove the headings for each group.
  • Scale down the patterns a great deal. Should fit 2 side by side.
  • Adjust the spacing of blocks. I'm happy to help here if need be.

The browse all — I can't recall where that discussion landed. Is it complicated to build?

@youknowriad
Copy link
Contributor Author

pushed some updates here per the comments. The Popover size and direction is still not adapting properly to the content height change. I explored some solutions but it's a bit challenging. Maybe @ellatrix could land a hand here when you find some time.

@mtias
Copy link
Member

mtias commented Jun 10, 2020

Have been giving this a run through over the past few days. The things that have stand out from the designs:

  • Initial state just with search didn't feel great. It seemed to over-optimize for search. The default state of showing 6 most used blocks seems better.
  • Patterns make sense to be included in searches but not on the empty / default state.
  • Continuing the browsing experience in the main sidebar inserter is going to be important.
  • I'm quite liking the smaller patterns in the inserter, I think an inserter that only opens with patterns is going to be super useful for certain contexts (sections, template parts, etc). I could even see it included in block placeholders.

@youknowriad
Copy link
Contributor Author

I think what's remaining here is the "browse all" link to the main inserter but the main blocker remains the fact that the popover doesn't adapt its height and position to the available space. It's done on first render but not as we search.

@mtias
Copy link
Member

mtias commented Jun 16, 2020

This is looking good. Once we address these I think we can merge:

  • Patterns cannot be inserted for me (get an error).
  • The "X" (from wordpress/icons) should replace the search icon.
  • The "browse all" should drop the border radius and needs a better focus style (cc @jasmussen).
  • Would it make sense to preserve the search term when switching to the main inserter?

It's also very frustrating to me that arrow keys closes the inserter.

@jasmussen
Copy link
Contributor

and needs a better focus style (cc @jasmussen)

Am aware, and haven't forgotten the tabs. I'm still looking for a good design, but in the meantime I pushed a change that at least fixes things:

focus

@youknowriad
Copy link
Contributor Author

Patterns cannot be inserted for me (get an error).
The "X" (from wordpress/icons) should replace the search icon.

These two items are implemented/fixed

Would it make sense to preserve the search term when switching to the main inserter?

Potentially, but maybe we can start without it first to avoid the added complexity (communication between block-editor and external module) and add later?

I'd appreciate another round of feedback here. thanks.

@enriquesanchez
Copy link
Contributor

Tested this one again on Safari + VoiceOver.

Keyboard navigation feels solid and predictable. I ran into some issues however when attempting to do a search.

1. The inserter's position shifted as soon as I started typing.

From

Screen Shot 2020-06-19 at 17 37 51

To

Screen Shot 2020-06-19 at 17 37 59

2. On the main inserter, after entering a search string I hear the number of results found, but I couldn't hear that in the quick inserter.

It'll be great to be able to also hear the number of returned results here.

3. The 'close' button for a search entry is labeled after the search string, and there's no indication that this is a reset or cancel button

Screen Shot 2020-06-19 at 17 31 16

In the above example, I only hear 'quo, button'. This problem is also present in the main inserter. I think it'll be best if the action could be communicated better. Something like 'Reset search'?

4. Focus is unpredictable after canceling/resetting a search

If I click the 'quo' button above, I then see this:

Screen Shot 2020-06-19 at 17 31 48

I'm not sure where my focus landed, it looks like somewhere in between the search field and the first block because if I do shift + tab I move my focus back to the search field, and with tab I move to the first block.

I think the expected behavior here would be to have the focus back in the search field because I'm canceling a search query after all.

5. The 'Browse all' button could include a bit more info for users of assistive technology

Screen Shot 2020-06-19 at 17 55 41

After I click it, I immediately hear that my focus is now on a search field, but I have no clue or context that I'm on the main inserter now. I think that the 'Browse all' button could be more descriptive of what will happen by including more context. Maybe something like ´aria-label="Browse all. This will open the main inserter panel in the editor toolbar."´?

Screen Shot 2020-06-19 at 17 59 55

Or something along those lines...

@youknowriad youknowriad merged commit 1bec21f into master Jun 24, 2020
@youknowriad youknowriad deleted the add/quick-inserter branch June 24, 2020 13:17
@github-actions github-actions bot added this to the Gutenberg 8.5 milestone Jun 24, 2020
@mtias
Copy link
Member

mtias commented Jun 24, 2020

Thanks for all the iterations here 🎈

@StevenDufresne
Copy link
Contributor

StevenDufresne commented Jun 29, 2020

@youknowriad @mtias Where does the block directory logic fit in?... on the eve of the block directory launch 😆.

Edit: The logic to trigger block directory searches live in the full feature inserter so it technically won't get triggered here. That may be purposeful, if so 👍 but it may be unexpected from a user standpoint.

@mtias
Copy link
Member

mtias commented Jul 1, 2020

It's similar to the autocomplete inserter, which is the one that more clearly should not integrate the block directory, in my opinion. The quick inserter is in-between — perhaps we should integrate it down the road but I'd prefer to continue to refine the experience first in the main inserter.

@jasmussen
Copy link
Contributor

I'm seeing an error in the beta widgets screen where searching doesn't work, giving this error:

search-items.js:118 Uncaught TypeError: Cannot read property 'filter' of undefined

@youknowriad
Copy link
Contributor Author

@jasmussen would you mind ticketing that, I can look later.

@jasmussen
Copy link
Contributor

Done: #23649

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Inserter The main way to insert blocks using the + button in the editing interface [Type] Enhancement A suggestion for improvement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants