Problem/Motivation

Follow up to #2957425: Allow the inline creation of non-reusable Custom Blocks in the layout builder

This is what the current Layout Builder UI looks like for creating inline blocks:

The current Layout Builder UI for inline block creation

This isn't what's in the mockups.

Proposed resolution

Make it look more like the mockups: https://projects.invisionapp.com/boards/KH3EPJMFNWR4Z

This is how it appears, as of patch #39:

With patch #39 applied

Remaining tasks

Do it.

User interface changes

Yes.

API changes

Dunno yet.

Data model changes

Dear Cthulhu, please no.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

tedbow created an issue. See original summary.

tedbow’s picture

Issue summary: View changes
tedbow’s picture

Assigned: Unassigned » tedbow

Taking a try at this

tedbow’s picture

Assigned: tedbow » Unassigned
Status: Active » Needs review
FileSize
7.53 KB

Here is first try.

It adds a "Add new block" button link to the top of the block list.

Because this #2948064: Layout Builder should support inline creation of Custom Blocks using entity serialization isn't done

  1. If you only have 1 Block the link goes to the /admin/structure/block/block-content
  2. If you have more the link goes to a listing of blocks plugins but uses "Custom" category list

Status: Needs review » Needs work

The last submitted patch, 4: 2968500-4.patch, failed testing. View results

tedbow’s picture

Status: Needs work » Needs review
FileSize
3.82 KB
8.85 KB

Fixing test failure. Needed to check if block_content_type is available.

tedbow’s picture

Status: Needs review » Needs work

The last submitted patch, 7: 2968500-7__2948064-43.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

tedbow’s picture

Status: Needs work » Needs review
FileSize
16.36 KB
30.97 KB
3.7 KB
  1. Fix fail in #7
  2. Also added new test method testAddWorkFlow() to test the workflow when you have 0, 1 or > 1 block types. Could have added this to testInlineBlocks() but I think having it as its own test is more clear.
tim.plunkett’s picture

How does this relate to #2957425: Allow the inline creation of non-reusable Custom Blocks in the layout builder with all the changes in the last 2 months?

tedbow’s picture

Title: Create UI for adding Inline Blocks in the off-canvas dialog in Layout Builder » Change Inline Blocks workflow in layout build to match mocks
Issue summary: View changes
Related issues: -#2948064: Layout Builder should support inline creation of Custom Blocks using entity serialization +#2957425: Allow the inline creation of non-reusable Custom Blocks in the layout builder
FileSize
16.23 KB
152.92 KB

Updating and rerolling

tedbow’s picture

Status: Needs review » Postponed

Yay, tests pass! 🎉

Postponing on #2957425: Allow the inline creation of non-reusable Custom Blocks in the layout builder.

That patch is already big enough I would rather not roll it in there.

Version: 8.6.x-dev » 8.7.x-dev

Drupal 8.6.0-alpha1 will be released the week of July 16, 2018, which means new developments and disruptive changes should now be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

tedbow’s picture

Status: Postponed » Needs work
samuel.mortenson’s picture

Assigned: Unassigned » samuel.mortenson

Going to work on a re-roll and CSS to match the mockup.

samuel.mortenson’s picture

Here's the re-roll and button label change to match mockup. Just CSS and a back button left.

tedbow’s picture

@samuel.mortenson thanks for getting this rolling again.

+++ b/core/modules/layout_builder/src/Controller/ChooseBlockController.php
@@ -60,8 +74,41 @@ public static function create(ContainerInterface $container) {
+          '#title' => $this->t('Create new content'),

I know this is the label in the mock-up but will this be problem because in the UI "content" usually refers to node entities.

It seems this would be implying you are creating a new node.

I could see a contrib module in the future or core adding the ability to add nodes directly in the layout builder.

samuel.mortenson’s picture

FileSize
17.85 KB
2.49 KB

This patch adds a "Back" button from the block listing, and lots of styling to make this flow feel unique compared to other blocks. The styling and functionality is ready for review.

I think #17 needs UX review.

AaronMcHale’s picture

Agree with #17, although can’t think of a better name myself.

@samuel.mortenson thanks for picking this up, hopefully we can get this RTBC and committed in 8.7

tedbow’s picture

Issue summary: View changes
FileSize
356.97 KB

Re #17

Instead of "Create new Content" why not just "Create a new block" and "Create a custom block"?

  1. We already have the "Custom block library" at /admin/structure/block/block-content and it has "Add custom block" I think it is important that users understand these are the same things and they are controlled by the same types. We shouldn't find a better name for here and leave the other 1 the same.
  2. "Custom block" would be respecting our the the label_singular for our block_content entity type. This is part of our API presumably this how contrib modules are told to refer to them in the UI.

    If don't respect that then we are going to have different modules referring blocks(or other entity types) by different labels. That would be very confusing to end users because they will not know that when they see "Add custom block" in 1 place "Add [our special label]" in another place that they can expect to be able to add the same types of things.

    i.e. If you have 3 custom block types for a site, Basic, Video, and Gallery when a user sees "Add custom block" in layout builder or the custom block library or Contrib module X or anywhere else on the site they can expect to see these types of things. Otherwise they have to remember for all the different places in the site where they see "Add [special label1]" that is actually the same type thing as "Add [special label2]"

    So if we use "Add custom block" a user seeing that in any location on their site can say to themselves "Oh yeah I have seen that before that will allow me to add a Video or Gallery block". And they can likely infer that if they have have not yet clicked the link in particular location if they have clicked similar link provided by another module.

  3. Other CMS's use the term Block.

    Wordpress's new Guttenberg
    Guttenberg add block screenshot
    Magento
    Maybe others?

AaronMcHale’s picture

@tedbow - I totally agree with you regarding the consistency of naming, my only concern is that users also associate custom blocks with being reusable and available anywhere on the site, the problem here is the blocks being added aren't reusable so that could also result in confusion for some users, for example "I added this custom block through Layout Builder, why is it not available anywhere else on the site, or even in any other Layout?".

I now have two competing thoughts in my head though:

The first is that in some ways it might almost be better for us to have that custom name for Custom Blocks since because they aren't reusable the end user (e.g. content editor, not a developer) doesn't need to know that technically they are just the same as any other block except they can't be reused.

My second thought is given that as soon as they click the "Add [whatever]" button it gives them a list of custom block types to choose from they might be confused as to what this list means, where it came from and how they can change it, especially if they have more than just Basic Block.

Unfortunately those two conflicting thoughts mean I'm not sure what the best way forward is, at the moment there doesn't seem to be a clear way forward that doesn't introduce at least some degree of possible confusion, but of course we need to do something so maybe there's a nice middle ground we can find somewhere.

samuel.mortenson’s picture

Assigned: samuel.mortenson » Unassigned
xjm’s picture

Status: Needs review » Needs work
Issue tags: +Needs screenshots, +Usability

Can we get a "before" screenshot so we can compare it to what's in the mockups?

phenaproxima’s picture

Issue summary: View changes
Issue tags: -Needs screenshots
FileSize
181.77 KB

Done.

bendeguz.csirmaz’s picture

Status: Needs work » Reviewed & tested by the community

I tested it, and it works.

The last submitted patch, 11: 2968500-11_plus_2957425-177.patch, failed testing. View results

tim.plunkett’s picture

Issue tags: +Blocks-Layouts
lauriii’s picture

Status: Reviewed & tested by the community » Needs work
Issue tags: +Needs reroll

The most recent patch doesn't apply anymore

tedbow’s picture

Status: Needs work » Reviewed & tested by the community
Issue tags: -Needs reroll
FileSize
17.62 KB

Just a reroll

  1. Reverted #2995078: Add a title to the off-canvas dialog when opened by clicking "Add Block"
  2. Applied patch in #18 again
  3. Reapplied changes in #2995078 which since 18 patch added StringTranslationTrait was now only
    $build['#title'] = $this->t('Choose a block');
lauriii’s picture

Status: Reviewed & tested by the community » Needs work
  1. +++ b/core/modules/layout_builder/css/layout-builder.css
    @@ -85,3 +85,33 @@
    +#drupal-off-canvas a.inline-block-create-button {
    ...
    +#drupal-off-canvas a.inline-block-create-button,
    ...
    +#drupal-off-canvas a.inline-block-create-button:hover,
    

    We should remove the element type from the selector. This should be only #drupal-off-canvas .inline-block-create-button.

  2. +++ b/core/modules/layout_builder/css/layout-builder.css
    @@ -85,3 +85,33 @@
    +#drupal-off-canvas .inline-block-list a {
    ...
    +#drupal-off-canvas .inline-block-list a:hover {
    ...
    +#drupal-off-canvas .inline-block-list a {
    

    Could we add class for the links in the list? Something like .inline-block-list__item.

  3. +++ b/core/modules/layout_builder/css/layout-builder.css
    @@ -85,3 +85,33 @@
    +  transition: background-color 0.5s;
    

    What is the reason for providing the transition? I tried to look at the Seven style guide but it doesn't mention anything about using transitions.

bendeguz.csirmaz’s picture

It turns out removing the anchor element from the create button's selector will make the css specificity too low, and it'll get overridden.
I decided to add a class to the container, and use that to combat this issue.
The other option, as @huzooka suggested, is to add a modifier class, and use that.

phenaproxima’s picture

Status: Needs work » Needs review

Kicking to review.

The last submitted patch, 29: 2968500-29.patch, failed testing. View results

lauriii’s picture

Status: Needs review » Needs work
+++ b/core/modules/layout_builder/css/layout-builder.css
@@ -86,7 +86,7 @@
+#drupal-off-canvas .choose-block-container .inline-block-create-button {

@@ -95,15 +95,14 @@
+#drupal-off-canvas .choose-block-container .inline-block-create-button,
+#drupal-off-canvas .inline-block-list .inline-block-list__item {
...
+#drupal-off-canvas .choose-block-container .inline-block-create-button:hover,
+#drupal-off-canvas .inline-block-list .inline-block-list__item:hover {

@@ -111,7 +110,7 @@
+#drupal-off-canvas .inline-block-list .inline-block-list__item {

We should always use a single class as a selector. Off-canvas is a special case where we add the id selector behind the class selector to increase the weight.

bendeguz.csirmaz’s picture

Fixed!
My previous comment was a false alarm.
I accidentally used the patch from #2952390: Off-canvas styles override CKEditor's reset and theme, thanks @lauriii for pointing that out.

bendeguz.csirmaz’s picture

Status: Needs work » Needs review
lauriii’s picture

Status: Needs review » Reviewed & tested by the community

Thanks for making the changes @bendeguz.csirmaz! The front end parts of the patch look good for me now.

webchick’s picture

Status: Reviewed & tested by the community » Needs work

My first reactions upon @phenaproxima showing this to me is that:

1) Yay, that's a WAY better UX!
but
2) Yikes, we can't call that "Create new content" because we already say that somewhere else and mean something entirely different. (This was brought up above as well.)

Apparently the team already went through a bike-shedding exercise and ended up at "Create custom block" (since this is the existing entity label), which sounds much better to me. The only potential weirdness there is we call other things custom blocks that are re-usable, and this one is for the page we're on only. So we should probably open a follow-up to discuss how to make this clearer to people. But it doesn't need to block this patch, which is pretty awesome on its own.

Since this is just a label change, feel free to move back to RTBC once this is done.

phenaproxima’s picture

Issue summary: View changes
Status: Needs work » Needs review
FileSize
17.88 KB
4.63 KB
132.92 KB

Changed "Create new content" to "Create custom block" and adjusted the tests. Also attaching an "after" screenshot for committer happiness.

phenaproxima’s picture

Found a typo that is fixable on commit:

+++ b/core/modules/layout_builder/tests/src/FunctionalJavascript/InlineBlockTest.php
@@ -428,4 +428,74 @@ public function testAccess() {
+    // Confirm with only 1 type the "Create custom block" link goes directly t
+    // block add form.

Should be "...goes directly to block add form."

phenaproxima’s picture

Title: Change Inline Blocks workflow in layout build to match mocks » Change inline blocks workflow in Layout Builder to match mocks

Fixing the issue title.

phenaproxima’s picture

Status: Needs review » Reviewed & tested by the community

Green is my favorite color. Returning to RTBC as per #38.

webchick’s picture

Status: Reviewed & tested by the community » Fixed

Awesome!!

Committed and pushed to 8.7.x and backported to 8.6.x. Thanks!

  • webchick committed 257cfc7 on 8.7.x
    Issue #2968500 by tedbow, bendeguz.csirmaz, samuel.mortenson,...

  • webchick committed 36cf1a2 on 8.6.x
    Issue #2968500 by tedbow, bendeguz.csirmaz, samuel.mortenson,...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.