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 Inserter experience when blocks cannot be inserted #60991

Closed
3 tasks
jameskoster opened this issue Apr 23, 2024 · 18 comments · Fixed by #62169
Closed
3 tasks

Improve Inserter experience when blocks cannot be inserted #60991

jameskoster opened this issue Apr 23, 2024 · 18 comments · Fixed by #62169
Assignees
Labels
[Feature] Inserter The main way to insert blocks using the + button in the editing interface [Type] Bug An existing feature does not function as intended

Comments

@jameskoster
Copy link
Contributor

jameskoster commented Apr 23, 2024

The problem

When opened, the Inserter checks where to place blocks and patterns. When the logic is unable to find an appropriate position then the UI turns up empty.

A common example is page editing in the site editor with the template preview turned on; if you select the Title or Featured Image block, then open the Inserter, you see this:

Screenshot 2024-04-22 at 14 50 49

It's quite unexpected to be presented with an empty Inserter, and the lack of explanation further confuses things.

Solution – always show blocks / patterns in the Inserter

  • When the block/pattern cannot be inserted in the target location (based on existing logic), place it in the 'closest' possible location instead.
  • When there are legitimately no insertable locations in the current document, show a modal when a block/pattern is clicked/dragged to inform the user.
  • Give additional prominence allowedBlocks. E.g. when a List block (or a descendant thereof) is selected, opening the Inserter could show:
A screenshot of the block Inserter with a new section titled 'Suggested' above all other block categories

The label can be polished in a PR. "Based on your selection" could be an alternative to "Suggested".

Original idea Ideally the Inserter should never appear empty, so as to eliminate that initial point of confusion.

One option could be to update the logic so that it falls back to the closest insertable location based on the current parameters. In the scenario above, 95% of the time that would result in blocks being added to the Content block which seems reasonable and expected.

When there are genuinely no insertable locations in the current document, a dialog could appear when a block / pattern is clicked or dragged that explains the situation.

cc @WordPress/gutenberg-design for other ideas.

@jameskoster jameskoster added [Type] Enhancement A suggestion for improvement. [Feature] Inserter The main way to insert blocks using the + button in the editing interface Needs Design Feedback Needs general design feedback. labels Apr 23, 2024
@jameskoster jameskoster moved this to Later in Design priorities Apr 23, 2024
@jasmussen
Copy link
Contributor

There's a bit more to it than that, not only does nothing show up, but if you search for blocks, you won't find anything, presumably because you can't insert in that container:
screenshot of the site editor with the title selected and an empty inserter

Both aspects of the same problem. One path forward is, as you say, finding the nearest insertable location, and then applying both to the inserter and search results, as well as where the block will be inserted.

The other path would be to at least add smarts to the inserter to explain that it isn't that no results are found, plainly, it's because you cannot insert blocks in this particular location for this or that reason.

@jameskoster
Copy link
Contributor Author

The other path would be to at least add smarts to the inserter to explain that it isn't that no results are found

I'm less a fan of this approach, mostly because; if the user opens the Inserter it's clear they want to insert a block. The message would help explain things, but ultimately doesn't help them with their goal.

There's a bit more to it than that

It may be worth considering the allowedblocks experience in the inserter more generally. For instance if you're writing a list, then want to use the Inserter to add an Image after it, this is a bit frustrating:

Screenshot 2024-04-23 at 12 22 18

You have to close the Inserter, click elsewhere in the document, then re-open. I wonder if it would be better to display all blocks, (with prominence given to allowedblocks), and if you select something outside of the allowed scope it just gets added to the closest possible location, e.g:

Screenshot 2024-04-23 at 12 26 13

@jasmussen
Copy link
Contributor

I'm less a fan of this approach, mostly because; if the user opens the Inserter it's clear they want to insert a block. The message would help explain things, but ultimately doesn't help them with their goal.

Agreed, I shared it almost rethorically to support the point that it really shouldn't be empty.

Good thoughts, though, I wonder what would be the smallest thing to do. Is it to have the suggested followed by all sections and ensure blocks in the all section insert in the nearest allowed context that follows after the selected block?

@jameskoster
Copy link
Contributor Author

Is it to have the suggested followed by all sections and ensure blocks in the all section insert in the nearest allowed context that follows after the selected block?

Perhaps this would be more work, but the upside is it would capture all of these flows.

I don't have strong opinions either way, but I find myself tripping over the example in the OP quite often, and would lean towards prioritising a fix for that if we want to try something laser-focussed.

@richtabor
Copy link
Member

richtabor commented Apr 23, 2024

You have to close the Inserter, click elsewhere in the document, then re-open. I wonder if it would be better to display all blocks, (with prominence given to allowedblocks), and if you select something outside of the allowed scope it just gets added to the closest possible location, e.g:

I agree with this sentiment. It's a bit of a needle to thread, but for blocks with restricted inner blocks—like the List block—it's unexpected to not see any other blocks. I wonder if another course of action would be to categorize/prioritize the blocks that can be inserted within the given block, (List Item block for example) and have all other blocks below it.

Edit: Ha, same as @joen mentioned:

Is it to have the suggested followed by all sections and ensure blocks in the all section insert in the nearest allowed context that follows after the selected block?

@richtabor
Copy link
Member

The other path would be to at least add smarts to the inserter to explain that it isn't that no results are found

I'm less a fan of this approach, mostly because; if the user opens the Inserter it's clear they want to insert a block. The message would help explain things, but ultimately doesn't help them with their goal.

Agreed. What would it read? Select a different block to add different blocks? 😅

@jameskoster
Copy link
Contributor Author

I wonder if another course of action would be to categorize/prioritize the blocks that can be inserted within the given block, (List Item block for example) and have all other blocks below it.

I guess my 2 second inspector mockup wasn't very clear 🙈, but this is exactly what I was getting at 👍

Overall the path forward seems to be:

  • Always show all blocks in the Inserter.
  • Give additional prominence allowedblocks.
  • When a block cannot be inserted (based on the existing logic), insert it in the closest location that can be found. Hopefully this isn't computationally expensive 🤞
  • When there are legitimately no insertable locations, show a dialog when a block/pattern is clicked/dragged.

Happy to mock this up in more detail, and update the OP if there's consensus.

@richtabor
Copy link
Member

This issue is closely related: #55151

@richtabor
Copy link
Member

Happy to mock this up in more detail, and update the OP if there's consensus.

Seems solid to me.

@richtabor
Copy link
Member

I'm noticing this also when a template part is selected; generally much more often lately.

I think we need to iron this out before 6.6.

@SaxonF
Copy link
Contributor

SaxonF commented Apr 24, 2024

Agree this should be prioritised

@jasmussen jasmussen moved this from Later to Next in Design priorities Apr 25, 2024
@draganescu
Copy link
Contributor

Partially synced patterns also cause this:

List items Partially synced
Screenshot 2024-04-26 at 17 10 24 Screenshot 2024-04-26 at 17 09 27

@draganescu
Copy link
Contributor

@jameskoster there is a broken picture in the description if you can remember what it was, after the text:

E.g. when a List block (or a descendant thereof) is selected, opening the Inserter could show:

@jameskoster
Copy link
Contributor Author

Oh, it's the same image as the one in this comment. Apparently github prefers me to upload the same image twice.

I updated the OP.

@annezazu
Copy link
Contributor

Adding this to the 6.6 board as I agree this is increasingly becoming more visible with some of the new features like overrides.

@jasmussen
Copy link
Contributor

jasmussen commented May 16, 2024

Here are a few takes on solutions. The main challenges to solve, as I perceive it:

  1. If I select a list block, and only see a list item, it begs the question: where are all the other blocks? You can drag and drop them anywhere, after all, even if they can't be inserted in the "List" block because only "List Item" is allowed.
  2. If I select a Title block in a locked template, no blocks are allowed inserted. The same question arises: where are all the blocks? Why can't I insert blocks?

The least we can do, it feels like, is to improve the messaging in the inserter.

Inserter - only show child blocks when selected

In this mockup, Title and List block cases. The Title block shows: "The container block is locked from new blocks." — This is not the best copy, and I'd appreciate advice, we can be as verbose as we need to here, but the message is, the inserter is contextual to the block you've selected, and if it's in a locked context, no blocks can be inserted.

This mockup does not address the probable confusion: "where are all my blocks", but it could hopefully be a first step to improve things.

A larger undertaking would involve showing all available blocks in a secondary list. Those blocks would not be possible to insert into locked contexts, so we'd need both visual separation, and a heuristic: where do they go then? The simplest I could think of is:

Inserter - Show allowed child blocks, and a secondary list to insert at the top level
  • When the Title block is selected but in locked context, the inserter will show the usual list of blocks, but those will be inserted at the root level of the document. After the current block, if possible.
  • When the List block is selected, it'll show a dedicated area at the top of the inserter, with child blocks that are allowed, in this case, "List item".
  • Similarly, other blocks are shown below a separator, and those will be inserted at the root level.

Let me know your thoughts.

Figma.

Note, I've edited this comment as a few things came to light after posting.

@annezazu
Copy link
Contributor

Quick thoughts: I dig this. I think all of this combined with enhancements to drag & drop, like showing a X when you can't drop something in a certain area, will help step us forward here.

@draganescu draganescu removed the Needs Dev Ready for, and needs developer efforts label May 23, 2024
@draganescu draganescu moved this from Needs Dev to In Dev in Design priorities May 23, 2024
@jasmussen
Copy link
Contributor

Coming back to this one, it's arguably a bug, and has been since the initial implementation. It's just become more visible with recent changes to the inserter.

@jasmussen jasmussen added [Type] Bug An existing feature does not function as intended and removed [Type] Enhancement A suggestion for improvement. labels May 31, 2024
@github-project-automation github-project-automation bot moved this from In Dev to Done in Design priorities May 31, 2024
@github-project-automation github-project-automation bot moved this from 📥 Todo to ✅ Done in WordPress 6.6 Editor Tasks May 31, 2024
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] Bug An existing feature does not function as intended
Projects
Status: Done
Status: Done
Development

Successfully merging a pull request may close this issue.

6 participants