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

Allow the column block in the inserter #20502

Merged
merged 4 commits into from
May 6, 2020

Conversation

youknowriad
Copy link
Contributor

closes #19354

Since the "column" block already has a "parent" property defined, we should just let it appear in the inserter if a sibling is selected, allowing you to insert another column to the columns block without using the "columns count" range.

Thoughts?

@youknowriad youknowriad requested a review from aduth February 27, 2020 13:59
@youknowriad youknowriad self-assigned this Feb 27, 2020
@youknowriad youknowriad added the [Block] Columns Affects the Columns Block label Feb 27, 2020
@youknowriad youknowriad force-pushed the update/allow-column-in-inserter branch from fe8729a to 2ccb0e4 Compare February 27, 2020 14:02
@github-actions
Copy link

github-actions bot commented Feb 27, 2020

Size Change: +238 B (0%)

Total Size: 821 kB

Filename Size Change
build/block-directory/index.js 6.6 kB +1 B
build/block-editor/index.js 101 kB +8 B (0%)
build/block-library/index.js 115 kB +148 B (0%)
build/blocks/index.js 48.1 kB -1 B
build/components/index.js 179 kB +9 B (0%)
build/data/index.js 8.44 kB -1 B
build/edit-post/index.js 28.1 kB +1 B
build/edit-site/index.js 12.3 kB +1 B
build/edit-widgets/index.js 8.37 kB +42 B (0%)
build/edit-widgets/style-rtl.css 4.68 kB +16 B (0%)
build/edit-widgets/style.css 4.68 kB +17 B (0%)
build/editor/index.js 44.3 kB -1 B
build/format-library/index.js 7.63 kB -1 B
build/viewport/index.js 1.84 kB -1 B
ℹ️ View Unchanged
Filename Size Change
build/a11y/index.js 1.02 kB 0 B
build/annotations/index.js 3.62 kB 0 B
build/api-fetch/index.js 4.08 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 760 B 0 B
build/block-directory/style.css 761 B 0 B
build/block-editor/style-rtl.css 10.2 kB 0 B
build/block-editor/style.css 10.2 kB 0 B
build/block-library/editor-rtl.css 7.08 kB 0 B
build/block-library/editor.css 7.08 kB 0 B
build/block-library/style-rtl.css 7.24 kB 0 B
build/block-library/style.css 7.25 kB 0 B
build/block-library/theme-rtl.css 683 B 0 B
build/block-library/theme.css 685 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 16.9 kB 0 B
build/components/style.css 16.9 kB 0 B
build/compose/index.js 6.66 kB 0 B
build/core-data/index.js 11.4 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 568 B 0 B
build/dom/index.js 3.1 kB 0 B
build/edit-navigation/index.js 4.05 kB 0 B
build/edit-navigation/style-rtl.css 485 B 0 B
build/edit-navigation/style.css 485 B 0 B
build/edit-post/style-rtl.css 12.2 kB 0 B
build/edit-post/style.css 12.2 kB 0 B
build/edit-site/style-rtl.css 5.19 kB 0 B
build/edit-site/style.css 5.2 kB 0 B
build/editor/editor-styles-rtl.css 428 B 0 B
build/editor/editor-styles.css 431 B 0 B
build/editor/style-rtl.css 5.07 kB 0 B
build/editor/style.css 5.08 kB 0 B
build/element/index.js 4.65 kB 0 B
build/escape-html/index.js 734 B 0 B
build/format-library/style-rtl.css 502 B 0 B
build/format-library/style.css 502 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 226 B 0 B
build/list-reusable-blocks/style.css 226 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 616 B 0 B
build/nux/style.css 613 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/rich-text/index.js 14.8 kB 0 B
build/server-side-render/index.js 2.67 kB 0 B
build/shortcode/index.js 1.7 kB 0 B
build/token-list/index.js 1.28 kB 0 B
build/url/index.js 4.02 kB 0 B
build/warning/index.js 1.14 kB 0 B
build/wordcount/index.js 1.18 kB 0 B

compressed-size-action

@aduth
Copy link
Member

aduth commented Feb 27, 2020

At a glance, it seems reasonable to me. It raises a question to me whether we even want the "Columns" slider at all, if we're starting to go down this path of letting users rearrange, add, and remove columns in-place.

@youknowriad
Copy link
Contributor Author

Yeah I had the same though but adding columns with the inserter is still a bit painful (you need to have the "columns" or "column" selected.

There's also something else, the range is limited to 6 columns I believe, do we need a "maxInnerBlocks" API or something? or is it ok to keep it as is. People can still add an illimited number in HTML.

@aduth
Copy link
Member

aduth commented Feb 27, 2020

That's an interesting point to highlight. It feels like something where, if we feel the need to have some restriction, we would want to allow blocks supports to be changed dynamically†. So, for example, the Columns block could dynamically set inserter: false when the maximum number of columns is reached. I don't know that it's common enough a use-case that we would want to optimize some generic solution (like maxInnerBlocks). Even for the existing Columns case, it's a pretty questionable restriction (and not enforced in any way at the markup level).

† Maybe it already is? Is there something to dispatch to the core/blocks store to change these supports after the initial registration?

@youknowriad
Copy link
Contributor Author

† Maybe it already is? Is there something to dispatch to the core/blocks store to change these supports after the initial registration?

I'm pretty sure it's possible but we don't have dedicated actions.

@youknowriad
Copy link
Contributor Author

Actually, no, it's not possible because we only want to do this change of a single instance.

@aduth
Copy link
Member

aduth commented Feb 27, 2020

Ah, I see how that's an issue. I could possibly imagine some hierarchy supporting optional per-instance block supports, but aside from this use-case, I'm not sure how useful that would be.

@aduth
Copy link
Member

aduth commented Feb 27, 2020

I tested this and it feels a little strange to me. Intuitively, I felt that I would add a Column to a Columns block. Accordingly, I selected the Columns block and clicked the inserter, but was presented with all block options, and not the Column block. Reflecting on this and how the inserter works in general (you're inserting relative the selected block in the context of the parent or root), I understand the technical reasons for why this is. But I wonder if my experiences will be a common source of confusion.

On the other hand, it could be argued that even if it's not optimized to insert this way, there will always be an inserter for when the Column is selected, so it may as well present something useful, rather than "No blocks found" (#19354). In that sense, I think it can be an okay change.

Copy link
Member

@aduth aduth left a comment

Choose a reason for hiding this comment

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

Code-wise, this looks correct. I'll leave it to your discretion on whether to proceed, given the thought process I shared at #20502 (comment).

@youknowriad
Copy link
Contributor Author

But I wonder if my experiences will be a common source of confusion.

I agree with this confusion and I had a similar feeling. The inserter works consistently no matter which block is selected: "insert after the block". We could potentially consider changing that into:

  • If the block supports inner blocks: insert inside the block
  • otherwise, insert after

Even with this, there's a potential for confusion though.

@youknowriad youknowriad requested review from nerrad and ntwb as code owners March 2, 2020 09:08
@jbinda
Copy link
Contributor

jbinda commented Mar 2, 2020

Together with @koke, @pinarol and @iamthomasbishop we were discussing how to approach Columns block on mobile. This PR help us a lot to handle Inserter behaviour. However I also wonder about other two related topics.

  1. How does it affects Column number restriction. Currently we can set Column number between 2 and 6 via Slider in Sidebar. I think adding Column via Inserter gives possibility to pass that limitation without further changes around Inserter logic.
  2. Shouldn't we also add remove option for Column in dropdown menu in BlockControls after block gets selection ? It's about being consistent - if you are able to add block via Inserter probably you would like to remove it as well in the same way as other blocks

What do you think about this ?

@youknowriad
Copy link
Contributor Author

if you are able to add block via Inserter probably you would like to remove it as well in the same way as other blocks

This is already the case.

@jbinda
Copy link
Contributor

jbinda commented Mar 2, 2020

Ok, great ! Thanks for answer

@koke
Copy link
Contributor

koke commented Mar 9, 2020

If we want to limit the column number to the 2-6 range, then any sort of direct manipulation makes the UX confusing. We could allow inserting columns and have that new API to limit the number of child blocks, but then it would not be clear to a user why sometimes they can insert and sometimes they can't. Similarly, if there are two remaining columns, it wouldn't be clear why they can't remove columns now. The slider might not be the most obvious way to manipulate the column number, but at least makes these limits explicit.

I'm wondering if there's a way to relax that restriction, making the 2-6 range more of a suggestion than a limit. That way, you would be able to insert as many columns as you like, and remove them all, leaving an empty columns block that would show the initial placeholder.

I don't know that it's common enough a use-case that we would want to optimize some generic solution (like maxInnerBlocks).

We came across another potential use case in wordpress-mobile/gutenberg-mobile#1607 (comment), where it would be interesting to refactor media-text so it uses inner blocks for the media part. I believe the current API doesn't allow both limiting to either image or video, and a maximum of one child block. You can either lock the template to an explicit block, or allow multiple children.

@jbinda
Copy link
Contributor

jbinda commented Mar 9, 2020

If we want to limit the column number to the 2-6 range, then any sort of direct manipulation makes the UX confusing

It seems that the max limitation is not necessary - it seems you can put as many Column as you want. Avoiding minimum Column limitation is more tricky because at first glance it was difficult to me to think about Columns with only one Column inside. However second thought was that there might be some use case and user would like to have Columns block with only one Column so why we should block it ?

If we're going to remove the limitation I also wonder do we still want to show slider in Sidebar settings ?

@youknowriad youknowriad force-pushed the update/allow-column-in-inserter branch from 1959715 to d69b767 Compare May 5, 2020 10:52
@youknowriad
Copy link
Contributor Author

Added a warning message if the columns count exceeds the maximum. What do you think @aduth ? I believe it's a bit better than trying to force a columns count.

@aduth
Copy link
Member

aduth commented May 5, 2020

Taking a fresh look at this, I find the previously-noted concerns interesting to consider. I agree that it feels odd to allow for this sort of direct manipulation where a "cap" exists (even if it's now a soft-cap).

For me, I think a cap could exist, but the current options for giving feedback to the user are non-ideal. I think the ideal case for me would be one where maybe the inserter option becomes grayed out with an inlined or tooltip message about how the maximum number of columns has been reached. It's obviously a bigger task than we might want to take on here, but it could be a useful inserter feature generally for blocks to leverage.

The notice is okay as far as providing feedback, and there's some prior art here with things like the Contrast Checker (give a user the freedom to make a poor choice, but inform them about it). But it could be strange that we only inform a user of a mistake after the fact (could be missed). I guess it comes down to a question of "How bad of a problem is it?". It may not really be that big of a problem for there to be many columns. Or at least, the user can use their own judgment to decide based on how it appears on their site.

I think the options I see here are one of:

  1. Abandon the pull request, considering these usability concerns.
  2. Keep the notice.
  3. Consider it blocked by some other effort to expose interfaces for "block insertion restrictions".

Might also be good to get some design/usability feedback as well.

@youknowriad
Copy link
Contributor Author

Abandon the pull request, considering these usability concerns.

One of the reason I don't want to abandon the PR is because it will allow the inbetween inserter to trigger to add columns when we introduce the horizontal alignment support. I believe @ellatrix is working on some of that.

@ellatrix
Copy link
Member

ellatrix commented May 5, 2020

Yes, I've been thinking it could be useful to have the block list appender visible for columns. Not sure what's the best conditions for it to be visible. When the last column is selected? When any block is selected? When the inner block list is selected as well? We also need to think about this together with other blocks like the navigation block, social icons, buttons... which should have the UI.

@youknowriad
Copy link
Contributor Author

Let's give this a try, it's easy to revert anyway.

@youknowriad youknowriad merged commit 245e21b into master May 6, 2020
@youknowriad youknowriad deleted the update/allow-column-in-inserter branch May 6, 2020 09:28
@github-actions github-actions bot added this to the Gutenberg 8.1 milestone May 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Columns Affects the Columns Block
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Columns block: No blocks found when using Top Toolbar Inserter while Column block is selected
5 participants