Problem/Motivation

In Layout Builder, when the user chooses the options "Add Block", "Configure Block", "Remove Block", "Add Section", "Remove Section", "Configure Section", a dialog opens. Once the dialog is open, there is no visual indication of the Block/Section is is acting on. In some cases, this active element is pushed out of the viewport. This can make working with dialogs very confusing.

Proposed resolution

  • The clicked element opening the dialog should remain within the viewport after the right panel appears (canvas resizing can push it out of view)
  • The area of the page the dialog is acting on should be highlighted.

Video of the solution for the six scenarios to be addressed

  • Add Section
  • Configure Section
  • Remove Section
  • Add Block (also demonstrates the clicked element scrolling back into view)
  • Configure Block
  • Remove Block (also demonstrates that contextual link hover behavior when a block is highlighted)

https://youtu.be/r2UlWDmuAxY

Remaining tasks

Reviews

User interface changes

Element triggering dialogs will be highlighted. If the dialog appearing pushes the element offscreen, the page will automatically scroll to bring the triggering element back into view.

API changes

None

Data model changes

N/A

Release notes snippet

N/A

CommentFileSizeAuthor
#129 interdiff.txt889 byteslauriii
#126 2994909-highlight-126-interdiff.txt698 bytestim.plunkett
#126 2994909-highlight-126.patch32.46 KBtim.plunkett
#123 2994909-123.patch32.46 KBtedbow
#123 interdiff-123.txt2.86 KBtedbow
#121 2994909-121.patch32.45 KBtedbow
#121 interdiff-114-121.txt13.96 KBtedbow
#114 2994909-114.patch27.72 KBtedbow
#114 interdiff-104-114.txt1.44 KBtedbow
#104 2994909-104.patch27.82 KBbnjmnm
#104 interdiff_99-104.txt3.49 KBbnjmnm
#104 configure-section-after.png21.83 KBbnjmnm
#104 configure-section-before.png21.57 KBbnjmnm
#100 interdiff-79-97.txt6.01 KBlauriii
#99 interdiff-97-99.txt2.7 KBtedbow
#99 2994909-99.patch27.79 KBtedbow
#97 Screen Shot 2019-03-08 at 00.36.22.png266.75 KBlauriii
#97 Screen Shot 2019-03-08 at 00.36.15.png277.57 KBlauriii
#97 Screen Shot 2019-03-08 at 00.35.53.png4.1 KBlauriii
#97 Screen Shot 2019-03-08 at 00.35.44.png4.42 KBlauriii
#97 Screen Shot 2019-03-08 at 00.35.34.png193.34 KBlauriii
#97 Screen Shot 2019-03-08 at 00.35.27.png196.28 KBlauriii
#97 Screen Shot 2019-03-08 at 00.35.22.png5.01 KBlauriii
#97 Screen Shot 2019-03-08 at 00.35.16.png5.21 KBlauriii
#97 2994909-97.patch27.8 KBlauriii
#79 cx-focus-beats-highlight.gif1.81 MBbnjmnm
#79 interdiff-77-cx-focus-beats-highlight.txt1.68 KBbnjmnm
#79 2994909-79-cx-focus-beats-highlight.patch32.16 KBbnjmnm
#79 highlight-dashed-while-focused.gif1.26 MBbnjmnm
#79 interdiff_77-highlight-dashed-while-focused.txt1.78 KBbnjmnm
#79 2994909-79-highlight-dashed-while-focused.patch32.26 KBbnjmnm
#79 highlight-over-focus.gif1.26 MBbnjmnm
#79 interdiff_77-highlight-over-focus.txt376 bytesbnjmnm
#79 2994909-79-highlight-over-focus.patch31.93 KBbnjmnm
#77 2994909-77-reroll.patch31.89 KBbnjmnm
#76 interdiff_74-76.txt5.46 KBbnjmnm
#76 2994909-76.patch31.74 KBbnjmnm
#74 interdiff_70-74.txt5.2 KBbnjmnm
#74 2994909-74-FAIL.patch31.19 KBbnjmnm
#74 2994909-74.patch31.2 KBbnjmnm
#70 2994909-70-FAIL.patch28.73 KBbnjmnm
#70 interdiff_69-70.txt5.58 KBbnjmnm
#70 2994909-70.patch28.74 KBbnjmnm
#70 contextual-link-over-highlight.png36.22 KBbnjmnm
#69 2994909-69.patch25.29 KBtedbow
#69 interdiff-67-69.txt1.51 KBtedbow
#67 2994909-67.patch25.05 KBtedbow
#67 interdiff-63-67.txt1.38 KBtedbow
#63 2994909-63.patch24.88 KBbnjmnm
#63 interdiff_61-63.txt4.7 KBbnjmnm
#61 2994909-61-reroll.patch24.51 KBbnjmnm
#58 2994909-58.patch24.4 KBbnjmnm
#58 interdiff_56-58.txt2.57 KBbnjmnm
#30 2994909-30.patch9.73 KBbnjmnm
#30 interdiff_28-30.txt5.55 KBbnjmnm
#30 with-highlight.png173.06 KBbnjmnm
#30 without-highlight.png157.33 KBbnjmnm
#30 highlight-out-of-viewport.gif735.74 KBbnjmnm
#30 highlight-inside-viewport.gif747.11 KBbnjmnm
#28 2994909-28.patch7.58 KBbnjmnm
#28 interdiff_25-28.txt2.48 KBbnjmnm
#26 black-highlight-dark-theme.gif865.56 KBbnjmnm
#25 2994909-25-highlight-slightly-more-louder-do-not-test.patch8.17 KBkostyashupenko
#25 2994909-25-highlight-slightly-louder-do-not-test.patch7.99 KBkostyashupenko
#25 2994909-25-highlight-only-do-not-test.patch7.65 KBkostyashupenko
#23 2994909-21-slightly-louder-plus-one.gif1.96 MBbnjmnm
#23 2994909-21-highlight-slightly-louder.png258.13 KBbnjmnm
#23 2994909-21-highlight-only.png229.99 KBbnjmnm
#21 2994909-21-highlight-slightly-more-louder-do-not-test.patch8.21 KBbnjmnm
#21 2994909-21-highlight-slightly-louder-do-not-test.patch8.03 KBbnjmnm
#21 2994909-21-highlight-only-do-not-test.patch7.69 KBbnjmnm
#18 interdiff-14-18.txt401 bytestedbow
#18 2994909-18.patch7.74 KBtedbow
#14 2994909-14.patch7.76 KBtedbow
#14 interdiff-12-14.txt5.74 KBtedbow
#12 add_block_bold.png120.02 KBtedbow
#12 add_section_bold.png63.87 KBtedbow
#12 2994909-12.patch5.61 KBtedbow
#12 interdiff-7-12.txt2.06 KBtedbow
#7 2994909-7.patch5.47 KBtedbow
#7 interdiff-4-7.txt1.02 KBtedbow
#4 2994909-4.patch5.43 KBsamuel.mortenson
#32 interdiff_30-32.txt2.02 KBbnjmnm
#32 2994909-32.patch9.75 KBbnjmnm
#33 Screen Shot 2019-02-03 at 11.00.20 PM.png173.2 KBKristen Pol
#33 Screen Shot 2019-02-03 at 11.00.37 PM.png132.12 KBKristen Pol
#35 2994909-grey-35.patch9.75 KBtim.plunkett
#40 2994909-40-twodialog-FAIL.patch9.16 KBbnjmnm
#42 2994909-42-test-only-FAIL.patch6.67 KBbnjmnm
#42 interdiff_40-42.txt14.55 KBbnjmnm
#42 2994909-42.patch18.28 KBbnjmnm
#44 edit-block.png358.69 KBbnjmnm
#44 remove-block.png194.47 KBbnjmnm
#44 configure-section.png245.13 KBbnjmnm
#44 remove-section.png281.57 KBbnjmnm
#46 interdiff-pre-reroll_42-46.txt21.38 KBbnjmnm
#46 2994909-46-test-x25.patch25.99 KBbnjmnm
#46 2994909-46.patch24.08 KBbnjmnm
#52 2994909-52-reroll.patch24.09 KBbnjmnm
#56 interdiff_52-56.txt2.74 KBbnjmnm
#56 2994909-56.patch24.17 KBbnjmnm
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

tim.plunkett created an issue. See original summary.

cilefen’s picture

Issue tags: +Usability
krismaye’s picture

Assigned: Unassigned » krismaye
Issue tags: +MWDS2018
samuel.mortenson’s picture

Status: Active » Needs review
FileSize
5.43 KB

Here's an attempt at this - I added the same "highlight" effect to blocks, which felt more consistent.

xjm’s picture

tedbow’s picture

Functionality look good to me.

Now that #2978964: Use Prettier for formatting core JavaScript is fixed we need to run
yarn run prettier
on all js patches.
After running this that
yarn run lint:core-js-passing
Now passes

krismaye’s picture

Assigned: krismaye » Unassigned
tim.plunkett’s picture

Issue tags: +JavaScript
+++ b/core/modules/layout_builder/js/layout-builder.es6.js
@@ -51,4 +51,18 @@
+      $(`[data-layout-builder-highlight-id="${id}"]`).addClass(

Are those backticks the right way to do this? I'm out of date on best practices here.
Can someone sign off on the JS stuff?

andrewmacpherson’s picture

Issue tags: +Accessibility

There might be an accessibility dimension to this, I'm still thinking about it. The notion of "grey out" suggests some information is being conveyed by colour alone, so this idea would need to address WCAG SC 1.4.1 Use of Color (level A).

Can we add some indicator to emphasize the relevant area itself, rather than merely de-emphasising the irrelevant areas?

Update: I mean a non-colour indicator for the relevant area. An icon, or a change in border style perhaps.

andrewmacpherson’s picture

tedbow’s picture

Addressing #10.

Changed the outline and made the text bolder in the link.

Here are screenshots

Add section with bold

Add bold with bold

andrewmacpherson’s picture

I like #12 - that's the sort of thing I had in mind.

  • It provides extra cues to identify the relevant region.
  • It's more robust with respect to ambient light, e.g. working near a window.
  • The change from a dashed outline to a solid one will carry over into Windows high-contrast mode, when the colours are all overridden.
  • It may also be picked up by magnifier users, including some who have the magnified and un-magnified versions side by side (e.g. on two monitors). Magnifier set-ups vary greatly, but I expect this extra clarity will help some users.

RTBC-worthy from the screenshots in #12, but I'll leave the code review to others more familiar with the layout builder controllers and JS.

tedbow’s picture

  1. @andrewmacpherson thanks for the detailed explanation in #13 about the advantages of the current approach!
  2. +++ b/core/modules/layout_builder/src/Controller/LayoutBuilderController.php
    @@ -183,6 +183,12 @@ protected function buildAddSectionLink(SectionStorageInterface $section_storage,
    +        'data-layout-builder-highlight-id' => implode('-', [
    +          'section',
    +          $storage_type,
    +          $storage_id,
    +          $delta,
    +        ]),
    

    I don't for the data-layout-builder-highlight-id we actually need the storage_type and the storage_id.

    The only case I could see for this is you have 2 layout builder administrations sections open on the same page at the same time. Meaning you configuring 2 separate layouts at once. I assume this is not something we support.

    If we remove the extra elements in the array I think we can just use string concatenation.

  3. Adding test that highlight class is added
GrandmaGlassesRopeMan’s picture

JavaScript here is 👍.

One thing to consider for future development would be to consider moving away from jQuery unless we absolutely need to use some of its features.

DyanneNova’s picture

Status: Needs review » Reviewed & tested by the community

This looks good to me for CSS and should be a nice UX improvement.

lauriii’s picture

Status: Reviewed & tested by the community » Needs work
  1. +++ b/core/modules/layout_builder/css/layout-builder.css
    @@ -114,3 +114,11 @@
    +[data-layout-builder-highlight-id].layout-builder-highlight {
    

    Any particular reason why this couldn't be just .layout-builder-highlight?

  2. +++ b/core/modules/layout_builder/css/layout-builder.css
    @@ -114,3 +114,11 @@
    +  z-index: 1;
    

    Not sure if this is the correct z-index. For example, contextual links are now rendered on top of this.

  3. +++ b/core/modules/layout_builder/css/layout-builder.css
    @@ -114,3 +114,11 @@
    +  font-weight: bolder;
    

    Is there a clear benefit in setting this? This font-weight is not commonly used in Drupal core and might be something that doesn't work very well with custom themes since they don't necessarily have font loaded for this weight.

  4. Currently, the overlay doesn't prevent interacting with the site. Is that intentional? I expected clicking on the overlay would lead into moving back to the main canvas.
tedbow’s picture

@lauriii thanks for the review

  1. The current is more specific and the functionality won't work if the attribute [data-layout-builder-highlight-id] was on the element too. I guess this also avoids accidently conflicting with a a theme is already working with the layout builder and is adding their own class .layout-builder-highlight.
  2. The contextual links will be highlight if you hoover them or if you are in "edit" mode. I think this is correct because we should not be stopping you from doing any other actions just focusing your attention on the location where the section or block will be placed.
  3. I wasn't aware Drupal core doesn't usually use this. I removed it and I think the effect still works.
  4. Yes I don't think want to stop the user from taking any other action. We are just helping make the connection with the new section or block that will be added and the location it will be added. If the user decides they don't want to complete the action they can still directly take another action in the layout builder. Or close the dialog to unhighlight and then take the action.
tedbow’s picture

Status: Needs work » Needs review
lauriii’s picture

The current is more specific and the functionality won't work if the attribute [data-layout-builder-highlight-id] was on the element too.

Could you elaborate since I don't think I quite understand this?

I guess this also avoids accidently conflicting with a a theme is already working with the layout builder and is adding their own class .layout-builder-highlight.

I don't think we should worry about this given that the module is in alphabeta stage. Also, this is not in Stable theme so we are allowed to make changes freely.

We should also update the issue summary with the approach taken on the overlay and get UX review specifically on that since it works differently than other overlays in Drupal.

bnjmnm’s picture

From #10,

There might be an accessibility dimension to this, I'm still thinking about it. The notion of "grey out" suggests some information is being conveyed by colour alone.... Can we add some indicator to emphasize the relevant area itself, rather than merely de-emphasising the irrelevant areas?

Similar concerns were brought up at the Tues Jan 15 UX meeting. Attached are a few variations highlighting the relevant area without any grey-out

  • 2994909-21-highlight-only-do-not-test.patch is identical to the patch in #18 but with the grey-out removed
  • 2994909-21-highlight-slightly-louder-do-not-test.patch builds on the above patch, but with some subtle (I hope) additional styling to the active area to help indicate its relevance.
  • 2994909-21-highlight-slightly-more-louder-do-not-test.patch builds on the above patch, with slightly more aggressive css
tedbow’s picture

@bnjmnm thanks for the extra patches for the variations. Could attach screenshots that show the differences. Thanks

bnjmnm’s picture

@tedbow Here are screenshot for each version. 2994909-21-slightly-louder-plus-one has a bit of css animation so I provided an animated gif for that one.

tedbow’s picture

Status: Needs review » Needs work
Issue tags: +Needs reroll
  1. 2994909-21-highlight-only-do-not-test.patch
    +++ b/core/modules/layout_builder/css/layout-builder.css
    @@ -114,3 +114,9 @@
    +  position: relative;
    +  z-index: 1;
    

    Would we still need these if we don't have overlay? Presummable nothing should be on top of the add section and block divs anyways.

  2. +++ b/core/modules/layout_builder/css/layout-builder.css
    @@ -50,6 +50,7 @@
    +  transition: outline .7s ease;
    
    @@ -114,3 +115,15 @@
    +  transform: scale(1.005, 1.005);
    

    I would vote against the animation in any of the solutions

Oh no! these already need rerolls

kostyashupenko’s picture

bnjmnm’s picture

Status: Needs review » Needs work
FileSize
865.56 KB

Thanks for the rerolls @kostyashupenko
I've hid the two variants we definitely wont be going with per #24 (2)

However, think we may need to explore something other than the current highlight-only approach. I tested this with a FE color scheme I used on a clients site last year. Unfortunately, the highlighting is almost indistinguishable from non-highlighted. I attached a gif demonstrating this.

The initially proposed gray-out approach would work with darker themes, but the reasons for moving away from this are valid ones.
I'll think over possible solutions that avoid the drawbacks of gray-out, while also accommodating a wider range of FE theme colors. Very interested in hearing suggestions.

bnjmnm’s picture

Discussed #26 outside of this issue and the conclusion was addressing darker color schemes is not in scope for this issue. Will provide a patch refining the approach selected in #24

bnjmnm’s picture

Status: Needs work » Needs review
FileSize
2.48 KB
7.58 KB

Re:
#24.1 The z-index and position are still necessary for the black outline to fully replace the blue dashed one.

#24.2 Excellent selection, that's what we'll go with.

Patch also has a tiny JS optimization and a nit fix.

phenaproxima’s picture

Issue tags: +Needs screenshots

Patch looks good. There's test coverage, minimal changes, and everything that's going on is pretty clear. I like it! However, I do think this issue could use some before/after screenshots, so I'm tagging it for that. Beyond that, I have two small points of feedback:

  1. +++ b/core/modules/layout_builder/js/layout-builder.es6.js
    @@ -51,4 +51,18 @@
    +    const id = $element
    +      .find('[data-layout-builder-target-highlight-id]')
    +      .attr('data-layout-builder-target-highlight-id');
    +    if (id) {
    +      $(`[data-layout-builder-highlight-id="${id}"]`).addClass(
    +        'layout-builder-highlight',
    +      );
    +    }
    

    This logic is confusing. Can it have a comment explaining what it's doing and, more importantly, why?

  2. +++ b/core/modules/layout_builder/tests/src/FunctionalJavascript/LayoutBuilderUiTest.php
    @@ -92,4 +92,29 @@ protected function assertModifiedLayout($path) {
    +    $this->assertCount(1, $page->findAll('css', '.layout-builder-highlight'));
    

    Pro-tip: I believe you could use $assert_session->elementCount() for a slightly cleaner assertion here, or anywhere you're asserting that some number of elements match a selector.

bnjmnm’s picture

Patch addresses:
#29.1 - added some detailed comments so it's actually clear what the JS does.
#29.2 - nice protip, changes made

I also spotted & addressed an additional UX issue in the dialog:aftercreate event listener. In some cases, the target element is scrolled out of view when the off canvas dialog appears. highlight-out-of-viewport.gif shows this occurring.

The solution in action can be seen with highlight-inside-viewport.gif

Screenshots:

Here's "Add Section" before the patch

Here it is after

Kristen Pol’s picture

Thanks for the updates. I noticed some very minor things. I'll try to test it now.

  1. +++ b/core/modules/layout_builder/js/layout-builder.es6.js
    @@ -51,4 +51,53 @@
    +  // Listener to highlight active Add Block/Add Section elements.
    

    Nitpick: For readability, perhaps:

    Add Block/Add Section => "Add Block" and "Add Section"

  2. +++ b/core/modules/layout_builder/js/layout-builder.es6.js
    @@ -51,4 +51,53 @@
    +     * data-layout-builder-highlight-id, which identifies its
    +     * unique delta/region.
    

    Nitpick: 80 char wrapping.

  3. +++ b/core/modules/layout_builder/js/layout-builder.es6.js
    @@ -51,4 +51,53 @@
    +     * data to create a data-layout-builder-target-highlight-id attribute.
    +     * The value of this attribute matches the data-layout-builder-highlight-id
    

    Nitpick: 80 char wrapping.

  4. +++ b/core/modules/layout_builder/js/layout-builder.es6.js
    @@ -51,4 +51,53 @@
    +       * target element is still visible in viewport. If not, scroll page
    +       * so target element is visible in its pre-click position.
    

    Nitpick: 80 char wrapping.

bnjmnm’s picture

Nits in #31 addressed, TY @kristen-pol

Kristen Pol’s picture

Status: Needs review » Reviewed & tested by the community
Issue tags: -Accessibility +accessibility
FileSize
173.2 KB
132.12 KB

Changes in interdiff look good. I tested it and the Add Section box is highlighted as expected. Marking RTBC.

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 32: 2994909-32.patch, failed testing. View results

tim.plunkett’s picture

Status: Needs work » Reviewed & tested by the community
Issue tags: -Needs screenshots
FileSize
9.75 KB
bnjmnm’s picture

Title: Grey out the non-essential parts of the page when adding a new section in Layout Builder » Highlight active section when adding a new section in Layout Builder
Issue summary: View changes
xjm’s picture

Issue summary: View changes

Embedding the SS in the IS.

lauriii’s picture

Status: Reviewed & tested by the community » Needs work

Sorry to bump this back but it seems like #17.1 is still unresolved.

lauriii’s picture

Issue tags: +Needs reroll
bnjmnm’s picture

Status: Needs work » Needs review
FileSize
9.16 KB

Discovered that highlight disappears when adding blocks/sections that require more than one dialog. For example, when choosing a Two Column layout, the highlight disappears when the column width options are loaded. Adding the failing patch here for now as I wanted to get this visible without waiting on a fix.

This patch is also a reroll.

Status: Needs review » Needs work

The last submitted patch, 40: 2994909-40-twodialog-FAIL.patch, failed testing. View results

bnjmnm’s picture

Status: Needs work » Needs review
Issue tags: -Needs reroll
FileSize
6.67 KB
14.55 KB
18.28 KB

This patch addresses additional use cases identified while testing

  1. As mentioned in #40, highlighting is not maintained if block/section configuration requires consecutive dialogs.
  2. No highlighting occurs when removing or configuring sections
  3. When configuring a block via contextual links, the nearest "Add Block" is highlighted, which is not the triggering element.

To address all the above issues, I added the data-layout-builder-target-highlight-id attribute to all (?) of the dialogs triggered by the layout builder UI. Added data-layout-builder-highlight-id attributes to existing blocks and sections, previously this attribute was only present for "Add Block" and "Add Section".

Tests were expanded to cover all the scenarios mentioned.

IS needs updating to reflect that highlighting should be added to all dialog-opening inputs, not just "Add Section"

The last submitted patch, 42: 2994909-42-test-only-FAIL.patch, failed testing. View results

bnjmnm’s picture

FileSize
358.69 KB
194.47 KB
245.13 KB
281.57 KB

Here are screenshots of the new areas receiving highlights. I'm also wondering if it would be beneficial to use a different outline color when "Remove" is selected, to make it more apparent what is being removed - particularly since the confirmation dialog does not visibly specify the item being removed.

Remove Section

Configure Section

Remove Block

Edit Block

tedbow’s picture

Status: Needs review » Needs work
  1. +++ b/core/modules/layout_builder/src/Form/ConfigureBlockFormBase.php
    @@ -180,6 +181,9 @@ public function doBuildForm(array $form, FormStateInterface $form_state, Section
    +    if (!isset($form['#attributes']['data-layout-builder-target-highlight-id'])) {
    +      $form['#attributes']['data-layout-builder-target-highlight-id'] = "block-$delta-$region";
    +    }
    

    Do we actually need to check if it is set? Would we ever want to preserve a different value? Could we just always set it?

  2. Looking now at the number of places we are setting data-layout-builder-target-highlight-id I wonder if at this point it would make sense to have highlightIdTrait with just getHightLightId()
    Where maybe you send it in a array with the keys you have and it creates the id for you.
  3. +++ b/core/modules/layout_builder/tests/src/FunctionalJavascript/LayoutBuilderUiTest.php
    @@ -116,4 +124,108 @@ protected function assertModifiedLayout($path) {
    +    $this->assertNotEmpty($assert_session->waitForElement('css', '.new-section.layout-builder-highlight[data-layout-builder-highlight-id="section-0"]'));
    

    I think you should also wait for off-canvas or some elemet on it to be visible. To avoid random test fails.

  4. +++ b/core/modules/layout_builder/tests/src/FunctionalJavascript/LayoutBuilderUiTest.php
    @@ -116,4 +124,108 @@ protected function assertModifiedLayout($path) {
    +    // Highlight is present with AddSectionController.
    

    need blank light before comment

  5. +++ b/core/modules/layout_builder/tests/src/FunctionalJavascript/LayoutBuilderUiTest.php
    @@ -116,4 +124,108 @@ protected function assertModifiedLayout($path) {
    +    $this->assertHighlightedElement('new-section');
    

    This confirm there is only 1 highlight section and it has the class *new-section* but there are 2 new-section elements on the page. I don't think it confirms the correct one is highlight. Maybe we should switch to sending in a selector instead of a class.

  6. +++ b/core/modules/layout_builder/tests/src/FunctionalJavascript/LayoutBuilderUiTest.php
    @@ -116,4 +124,108 @@ protected function assertModifiedLayout($path) {
    +    // Highlight is present with ConfigureSectionForm.
    

    need blank light before comment

  7. +++ b/core/modules/layout_builder/tests/src/FunctionalJavascript/LayoutBuilderUiTest.php
    @@ -116,4 +124,108 @@ protected function assertModifiedLayout($path) {
    +    // Highlight is present with ChooseBlockController::build().
    

    need blank light before comment

  8. +++ b/core/modules/layout_builder/tests/src/FunctionalJavascript/LayoutBuilderUiTest.php
    @@ -116,4 +124,108 @@ protected function assertModifiedLayout($path) {
    +    // Highlight is present with ChooseBlockController::inlineBlockList().
    

    need blank light before comment

  9. +++ b/core/modules/layout_builder/tests/src/FunctionalJavascript/LayoutBuilderUiTest.php
    @@ -116,4 +124,108 @@ protected function assertModifiedLayout($path) {
    +    $page->pressButton('Close');
    +    $assert_session->assertWaitOnAjaxRequest();
    +    $assert_session->elementsCount('css', '.layout-builder-highlight', 0);
    

    I am wondering if it would be safer to copy waitForNoElement()(with the todo) from one of the other layout_builder js test. Then we can wait to explicitly that for the highlight to be take away and nto have to worry about timing issues.

    Probably also want to wait for no off-canvas dialog. before proceeding with test.

  10. +++ b/core/modules/layout_builder/tests/src/FunctionalJavascript/LayoutBuilderUiTest.php
    @@ -116,4 +124,108 @@ protected function assertModifiedLayout($path) {
    +    // Highlight is present with ConfigureBlockFormBase::doBuildForm.
    

    need blank light before comment

  11. +++ b/core/modules/layout_builder/tests/src/FunctionalJavascript/LayoutBuilderUiTest.php
    @@ -116,4 +124,108 @@ protected function assertModifiedLayout($path) {
    +    $page->pressButton('Close');
    +    $assert_session->assertWaitOnAjaxRequest();
    

    Here we should allow wait for dialog to close(noElement). I don't think there is any ajax request on close.

  12. +++ b/core/modules/layout_builder/tests/src/FunctionalJavascript/LayoutBuilderUiTest.php
    @@ -116,4 +124,108 @@ protected function assertModifiedLayout($path) {
    +    // Highlight is present when Remove section dialog open.
    

    need blank light before comment

  13. +++ b/core/modules/layout_builder/tests/src/FunctionalJavascript/LayoutBuilderUiTest.php
    @@ -116,4 +124,108 @@ protected function assertModifiedLayout($path) {
    +    $this->clickContextualLink('.block-field-blocknodebundle-with-section-fieldbody', 'Remove block');
    

    I think because of #2918718: Using ContextualLinkClickTrait::clickContextualLink() multiple times per page can cause random failures we want to reload the page before the second use of clickContextualLink() here.

  14. +++ b/core/modules/layout_builder/tests/src/FunctionalJavascript/LayoutBuilderUiTest.php
    @@ -116,4 +124,108 @@ protected function assertModifiedLayout($path) {
    +    $page->pressButton('Close');
    +    $assert_session->assertWaitOnAjaxRequest();
    +    $assert_session->elementsCount('css', '.layout-builder-highlight', 0);
    

    waitForNoElement()

bnjmnm’s picture

This patch addresses everything in #45, created a trait with four methods for generating a highlight ID, to cover the add & update scenarios for both sections and blocks.

Also added a x25 test patch because these UI-heavy tests (particularly ones with contextual links) seem prone to random failures.

This required a reroll, but the interdiff provided is pre-reroll, in case that aids the review process.

The last submitted patch, 46: 2994909-46-test-x25.patch, failed testing. View results

Kristen Pol’s picture

Does this need manual testing?

bnjmnm’s picture

@kristen-pol - thank you for asking! Manual testing would be great, particularly since the highlighting has been expanded to include existing blocks and sections, not just "Add Block" and "Add Section"

One of the things I'm most interested in is any scenarios where it seems like there should be focus and there isn't, especially since it took us a while to identify the need for highlighting existing Blocks/Sections.

Also interested in feedback about making the outline for "Remove Block"/"Remove Section" red instead of black. On the plus side: it could add a little gravitas to a potentially regretful operation -- particularly since currently it's kind of easy to mistakenly remove a section when it looks like it should just remove a block. On the down side: it deviates from the highlighting pattern people will be accustomed to at that point.

bnjmnm’s picture

Title: Highlight active section when adding a new section in Layout Builder » Highlight active element while working with dialogs in Layout Builder
Issue summary: View changes
andrewmacpherson’s picture

putting this back on my list, the screenshots after #30 look significantly different to what I reviewed in #13

bnjmnm’s picture

♻️🥖 Reroll

andrewmacpherson’s picture

Can somebody summarize the design changes since the accessibility review in #13, and the reasons for them? I'm lost.

bnjmnm’s picture

Can somebody summarize the design changes since the accessibility review in #13, and the reasons for them? I'm lost.

That is a very reasonable request, @andrewmacpherson. The discussions that led to the changes since #13 took place at weekly UX meetings -- very little of that is documented here and it should have been.

My recollection of the the primary concerns about the gray-out approach:

  • Visually, the interaction is very similar to that of using a modal despite all grayed elements on the page remaining active. Making this actually function as a modal was ruled out fairly quickly -- the reason I recall is the complexity to both the user and developer as the existing use of off-canvas means dealing with multiple interacting dialogs in the same interface
  • The grayed parts of the page, despite being active elements, are difficult for some users to see. Tab navigation the grayed elements can be difficult as well. For example. the contrast ratio of the gray-out and Chrome's default focus outline is only 1:40 to 1

(if this seems incomplete I can review the UX meeting recordings)

Several different approaches were discussed, and the agreement landed on highlighting the element that corresponds to the active off-canvas dialog with a 3px black outline.

tedbow’s picture

Status: Needs review » Needs work
  1. +++ b/core/modules/layout_builder/tests/src/FunctionalJavascript/LayoutBuilderUiTest.php
    @@ -116,4 +124,139 @@ protected function assertModifiedLayout($path) {
    +    $assert_session->assertWaitOnAjaxRequest();
    +    $this->assertNotEmpty($assert_session->waitForLink('Create custom block'));
    

    waitForLink() doesn't wait for visibility so usually I do something like
    $this->assertNotEmpty($assert_session->waitForElementVisible('css', 'a:contains("Link test")');

  2. +++ b/core/modules/layout_builder/tests/src/FunctionalJavascript/LayoutBuilderUiTest.php
    @@ -116,4 +124,139 @@ protected function assertModifiedLayout($path) {
    +    $assert_session->assertWaitOnAjaxRequest();
    +    $this->assertNotEmpty($assert_session->waitForLink('Recent content'));
    

    Same here

  3. +++ b/core/modules/layout_builder/tests/src/FunctionalJavascript/LayoutBuilderUiTest.php
    @@ -116,4 +124,139 @@ protected function assertModifiedLayout($path) {
    +    $assert_session->waitForElement('css', "#drupal-off-canvas");
    

    This doesn't assert it is not empty.
    Also should use waitForElementVisible() instead.

  4. +++ b/core/modules/layout_builder/tests/src/FunctionalJavascript/LayoutBuilderUiTest.php
    @@ -116,4 +124,139 @@ protected function assertModifiedLayout($path) {
    +    $assert_session->waitForElement('css', "#drupal-off-canvas");
    

    This doesn't assert it is not empty.
    Also should use waitForElementVisible() instead.

bnjmnm’s picture

Status: Needs work » Needs review
FileSize
24.17 KB
2.74 KB

Updated tests per review in #55

tedbow’s picture

Status: Needs review » Needs work
  1. +++ b/core/modules/layout_builder/tests/src/FunctionalJavascript/LayoutBuilderUiTest.php
    @@ -203,17 +203,17 @@ public function testAddHighlights() {
    -    $assert_session->waitForElement('css', "#drupal-off-canvas");
    +    $assert_session->waitForElementVisible('css', "#drupal-off-canvas");
    

    This should still be wrapped in $this->assertNotEmpty()

    There is another instance like this in the test.

+++ b/core/modules/layout_builder/js/layout-builder.es6.js
@@ -160,4 +160,55 @@
+       * Wait 700ms for the off canvas dialog to fully appear. Then see if
+       * target element is still visible in viewport. If not, scroll page so
+       * target element is visible in its pre-click position.

I think this should say "to appear and for the page to be sized"

Isn't the resizing of the page the reason the element might get pushed out of the ViewPort?

Also created #3033410: Ensure that links that opening the off-canvas dialog are in the viewport after the dialog is open because I checked and this existing problem with the Setting Tray module. But could also affect any link using the off-canvas dialog.

So we should put a @todo here to find a general solution in that issue and get rid the custom solution here.

I tried to actually respond to one of the resize events fired in off-canvas.es6.js so that we won't need the wait but instead scroll after the page is resized. I couldn't get it work. So I think we general solution in the follow.

bnjmnm’s picture

Status: Needs work » Needs review
FileSize
2.57 KB
24.4 KB

Per #57

  1. Wrapped items in $this->assertNotEmpty()
  2. Changed comment from ...to fully appear to ...to appear and for the page to be sized
  3. Added @todo to that comment
tedbow’s picture

Changes in #58 look good to address my review in #57

thanks, This issue is RTBC worthy in my opinion but we have needs accessibility review

Looks like @andrewmacpherson wants to take another look

bnjmnm’s picture

Issue summary: View changes
Issue tags: -Needs issue summary update
bnjmnm’s picture

Status: Needs review » Needs work

The last submitted patch, 61: 2994909-61-reroll.patch, failed testing. View results

bnjmnm’s picture

Status: Needs work » Needs review
FileSize
4.7 KB
24.88 KB

After the reroll, tests will not pass without disabling css animation. For good measure, I also added assertWaitOnAjaxRequest() after the tests AJAX requests.

tedbow’s picture

Status: Needs review » Reviewed & tested by the community

Looks good!

xjm’s picture

+++ b/core/modules/layout_builder/css/layout-builder.css
@@ -118,3 +118,9 @@
+  z-index: 1;

I've seen the z-index brought up twice here already. @bnjmnm points out that it's necessary for it to be > 0, but what @lauriii asked I believe is whether 1 is high enough.

The JavaScript maintainer formerly known as @drpal (FKAdrupal) already signed off on the JS here, so I'm comfortable reviewing this for commit if we can confirm we've sufficiently address @lauriii's previous feedback about the z-index.

tedbow’s picture

Status: Reviewed & tested by the community » Needs work
+++ b/core/modules/layout_builder/js/layout-builder.es6.js
@@ -195,4 +195,61 @@
+  $(window).on('dialog:afterclose', () => {
+    $('.layout-builder-highlight').removeClass('layout-builder-highlight');

We need to check here that Drupal.offCanvas.isOffCanvas($element)
otherwise the block configure forms could actually open up modal themselves in the case they are using ckeditor and other custom code.. If we don't check we remove the highlight when the modal is closed.

tedbow’s picture

Status: Needs work » Needs review
FileSize
1.38 KB
25.05 KB

here is the fix for #66

bnjmnm’s picture

Status: Needs review » Needs work

Very good catch @tedbow. Checked this locally and it looks like a similar conditional needs to be added to 'dialog:aftercreate', otherwise the highlight is removed in the same manner. To reproduce, add a custom block and use ckeditor to add a link to the body field. Without adding a check it 'dialog:aftercreate', the highlighting goes away as soon as the "add link" modal appears.

tedbow’s picture

Status: Needs work » Needs review
FileSize
1.51 KB
25.29 KB

@bnjmnm thanks for checking this and catching the other case.

The interdiff was created with git diff -w to ignore whitespace.

bnjmnm’s picture

While confirming the z-index: value is fine for #65, I adiscovered that if the cursor hovers over a highlighted block's contextual link button, the highlighting goes away due to a css rule from the contextual module .contextual-region.focus taking priority. I addressed this by changing the .layout-builder-highlight selector to #layout-builder .layout-builder-highlight. Tests were modified to check for this, so a fail patch is included.

The z-index: 1 provides the results that I think work best to see, at least. It properly takes precedence over the blue dashed outlines, but contextual links appear over it and available for use.

Anything else with static positioning should not be a concern as it would be contained inside the outline. If there are other use cases where the blocks contain non-statically positioned elements from core, hopefully the reviewer can point those out.

This patch includes the changes from #3035669: Block contextual links intermittently ignore mouseup, otherwise the tests would return a false positive.

Status: Needs review » Needs work

The last submitted patch, 70: 2994909-70-FAIL.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

tedbow’s picture

  1. +++ b/core/modules/layout_builder/tests/src/FunctionalJavascript/LayoutBuilderDisableInteractionsTest.php
    @@ -214,6 +214,13 @@ protected function assertContextualLinksClickable() {
    +    // its contextual link button. This confirms that contexual link mouseup
    

    contextual misspelled.

  2. +++ b/core/modules/layout_builder/tests/src/FunctionalJavascript/LayoutBuilderDisableInteractionsTest.php
    @@ -214,6 +214,13 @@ protected function assertContextualLinksClickable() {
    +    $assert_session->waitForElementVisible('css', '.search-block-form.focus');
    

    should be surrounded by $this->assertNotEmpty()

tedbow’s picture

+++ b/core/modules/layout_builder/tests/src/FunctionalJavascript/LayoutBuilderDisableInteractionsTest.php
@@ -214,6 +214,13 @@ protected function assertContextualLinksClickable() {
     $this->clickContextualLink('.block-field-blocknodebundle-with-section-fieldbody [data-contextual-id^="layout_builder_block"]', 'Configure');
     $this->assertNotEmpty($assert_session->waitForElementVisible('css', '#drupal-off-canvas'));
+
+    // Check if contextual link container can get 'focus' class after clicking
+    // its contextual link button. This confirms that contexual link mouseup
+    // events are not disabled by the Layout Builder UI.
+    $this->toggleContextualTriggerVisibility('.search-block-form');
+    $page->pressButton('Open Search form configuration options');
+    $assert_session->waitForElementVisible('css', '.search-block-form.focus');

Running the test locally it seems there fail I get is because the off canvas is in front of the contextual link. Does the off-canvas dialog have to open for the test to prove what is proving or could we close it again?

I testing adding a second

$page->pressButton('Close');
$this->assertNoElementAfterWait('#drupal-off-canvas');

right before and it does fix that exact failure for me locally

bnjmnm’s picture

Status: Needs work » Needs review
FileSize
31.2 KB
31.19 KB
5.2 KB

Addressed the feedback in #72

Re: #73The test needs to happen with the dialog open. The problem is the supression of a mouseup event, so once another click happens the fail condition goes away. Hopefully the inconsistency is addressed as I rewrote the test so simulates the drag behavior that causes the problem with real-world use.

GrandmaGlassesRopeMan’s picture

Status: Needs review » Needs work
Issue tags: +Needs JavaScript review
+++ b/core/modules/layout_builder/js/layout-builder.es6.js
@@ -195,4 +201,65 @@
+        /*
+         * Wait 700ms for the off canvas dialog to appear and for the page to be
+         * sized. After this, see if target element is still visible in viewport.
+         * If not, scroll page so target element is visible in its pre-click
+         * position.
+         *
+         * @todo Replace this custom solution when a general solution is made
+         *   available with https://www.drupal.org/node/3033410
+         */
+        setTimeout(() => {
+          const targetTop = $target.offset().top;
+          const targetBottom = targetTop + $target.outerHeight();
+          const viewportTop = $(window).scrollTop();
+          const viewportBottom = viewportTop + $(window).height();
+          const scrollAmount = targetTop - targetTopPreResize;
+          if (targetBottom < viewportTop || targetTop > viewportBottom) {
+            window.scrollBy({
+              top: scrollAmount,
+              left: 0,
+              behavior: 'smooth',
+            });
+          }
+        }, 700);

I haven't had a chance to review all of patch, but I did want to strongly urge you to not use `setTimeout`. Any time you have to wait for an arbitrary amount of time for the browser to complete an action, it's a signal of a larger issue. Imagine this being run on a slow computer, or the test environment which will behave differently than the environment that the 700ms was decided on.

I saw that you have a `@todo` for this, and thats great. I would suggest blocking further development on this issue until you solve this problem. Perhaps dispatching an event when whatever you are waiting on is complete and listening for it here?

bnjmnm’s picture

Status: Needs work » Needs review
FileSize
31.74 KB
5.46 KB

I wasn't particularly comfortable with the timeout either so I'm happy to get the push from @alwaysworking in #75 to revisit it - found a solution that should be much less fragile.

The 700ms was to wait for a css transition in off-canvas to complete.

.dialog-off-canvas-main-canvas {
  transition: padding-right 0.7s ease, padding-left 0.7s ease, padding-top 0.3s ease;
}

I added an event listener that fires when the transition completes. The listener does roughly the same thing as the timeout, aside from the scroll amount being computed differently since there isn't access to the element's prior position.

 const mainCanvas = document.querySelector('[data-off-canvas-main-canvas]');

    // This event fires when canvas css transitions are complete.
    mainCanvas.addEventListener('transitionend', () => {
      const $target = $('.layout-builder-highlight');

      if ($target.length > 0) {
        // These four variables are used to determine if element in viewport.
        const targetTop = $target.offset().top;
        const targetBottom = targetTop + $target.outerHeight();
        const viewportTop = $(window).scrollTop();
        const viewportBottom = viewportTop + $(window).height();

        // If element not in viewport, scroll it into view.
        if (targetBottom < viewportTop || targetTop > viewportBottom) {
          const viewportMiddle = (viewportBottom + viewportTop) / 2;
          const scrollAmount = targetTop - viewportMiddle;
          window.scrollBy({
            top: scrollAmount,
            left: 0,
            behavior: 'smooth',
          });
        }
      }
    });
bnjmnm’s picture

Reroll +
Also - because it may be easy to miss at this point - reminder from #70 that the JS changes in behaviors.layoutBuilderDisableInteractiveElements and changes to LayoutBuilderDisableInteractionsTest come from #3035669: Block contextual links intermittently ignore mouseup and are necessary for the test to not return a false positive.

lauriii’s picture

Status: Needs review » Needs work
+++ b/core/modules/layout_builder/css/layout-builder.css
@@ -114,3 +114,9 @@
+#layout-builder .layout-builder-highlight {

Using this method isn't sufficient for overriding the contextual styles. If we want to specifically override the contextual selector, we could just use this selector: .layout-builder-highlight.focus. However, I'm a bit concerned if removing the focus styles will be acceptable.

bnjmnm’s picture

Since #78 was a bit open ended (overriding the focus styles vs. preserving what contextual provides), I've provided three options, gifs that demonstrate what they do, and the tests have been modified for each version to account for the differences.

  1. 2994909-79-highlight-over-focus: contextual focus outlines are never visible if the element has .layout-builder-highlight
  2. highlight-dashed-while-focused - a focused contextual region with .layout-builder-highlight will have a black dashed outline instead of the default blue
  3. cx-focus-beats-highlight - .layout-builder-highlight does not apply any outline on focused contextual regions. (note there is still overlap with the outline applied to .layout-builder__region which would be outside the scope of this issue)
tim.plunkett’s picture

Issue tags: +Layout Builder stable blocker, +Layout Builder frontend issue

This blocks a stable blocker.

tedbow’s picture

Status: Needs review » Reviewed & tested by the community

re #75 @alwaysworking agreed we should get rid of the timeout

re #76 This works well and doesn't rely on the specific timeout value.
I have tested in manually and the scrolling still works as expected!

re #79
I think cx-focus-beats-highlight is the best solution here.

It keeps the styles of the contextual module which also may have been customized by a particular theme. I don't like highlight-dashed-while-focused because it kind of assumes contextual will have dashed line and we don't this for any particular theme. 3) seem to assume the least about how contextual styling will look.

xjm’s picture

Status: Reviewed & tested by the community » Needs review
Issue tags: +Needs usability review, +Needs frontend framework manager review

There are three patches in #79. When we RTBC an issue, let's make sure the solution chosen is uploaded by itself so we don't accidentally commit the wrong thing. :)

I think @tedbow is saying that #layout-builder .layout-builder-highlight:not(.focus) is what he RTBCed, but I looked at the gif of that and it's a weird and disorienting behavior.

It looks like a bug and it would confuse me if I were the user. I think this needs UX and a11y feedback.

This is already tagged for accessibility review, so we need that signoff before this is marked RTBC. I'm also going to specifically tag it for frontend framework manager review given recent discussion. Thanks!

xjm’s picture

Updating issue credit to include topic reviewers.

andrewmacpherson’s picture

It's not clear which patch the RTBC is about. I'm still confused about what is being proposed. There's talk of focus styles now?

andrewmacpherson’s picture

@xjm - "Weird and disorientating" is a bit vague. Can you explain in more detail? I'm having trouble following that animated GIF in #82. It's too fast and it loops so I can't tell what sequence of events it's supposed to depict.

tedbow’s picture

re #72 sorry for RTBC'ing this to early.
I actually have change my opinion from #81. I detail my reasons below.

@andrewmacpherson hopefully I can clear up what is going on here with the focus styling.

  1. This issue adds a border to highlight the current thing that is being configured, removed, or added in off-canvas dialog using the layout builder
  2. This could be a section or a block
  3. for an existing block the highlight block also has a contextual link trigger
  4. The context module in also provides a focus style for the thing the context link trigger corresponds to. from core/modules/contextual/css/contextual.theme.css

    from <code>core/modules/contextual/css/contextual.theme.css

    /**
     * Contextual region.
     */
    .contextual-region.focus {
      outline: 1px dashed #d6d6d6;
      outline-offset: 1px;
    }
    
  5. in #78 @lauriii pointed out that our highligh border won't override the contextual focus style when as for block the div that contextual module highlights via .contextual-region.focus selector is exactly the same as the div we highlight with .layout-builder-hightlight
  6. so the 3 solutions @bnjmnm proposed in #79 where 3 different solutions the problem
  7. Since the gifs are hard to demonstrate here is short video with all the possible solutions: https://youtu.be/zhVPFTJFGHw

After making the video and looking at the solutions in detail I now think we should use the patch 2994909-79-highlight-over-focus.patch

As you will see in the video in this solution if the block is highlighted via layout builder because it is being configured(or removed) in the off-canvas it does not apply the highlighting from the contextual module when the blocks is in focus. The contextual trigger is still highlighted.

The reason I think this is good is because the purpose of the contextual modules css to highlight the element that the contextual link trigger will effect is to let the user know what part of the page they will be affecting if they use the contextual links connected to the trigger.

Since in this case the part of the page they will be affecting is the block in the layout builder which already has a highlight then I don't think we need an extra highlight.

tim.plunkett’s picture

Issue tags: -accessibility (duplicate tag) +Accessibility

Fixing tag

DyanneNova’s picture

I'm inclined towards the first behavior. Highlighting the same way everywhere for contextual links makes that action feel more consistent.

lauriii’s picture

Lack of focus effect doesn't necessarily cause critical problems for mouse users. If we completely remove the focus effect, it means that the only indication of the area being focused is the contextual link icon, which is very subtle.

@DyanneNova would your concerns be addressed if we could come up with an alternative design where focus and the highlight work together in a more elegant way?

andrewmacpherson’s picture

I've watched the video from #86, and tried all the patches from #77 and #79

Firstly, there is a very confusing terminology problem in the comments here. Lots of comments talk about focus, but all the GIFs and videos show mouse hover behaviour only. Are you actually talking about focus? (i.e. document.activeElement, the :focus pseudoclass, the tabbing order, and all that.)

It seems what you are actually talking about is styling a container DIV, when the mouse hovers over it, or a control inside the container has keyboard focus (i.e. what :focus-within is for, once all the browsers support it). However the container itself doesn't get focus, so the WCAG "Focus visible" success criterion does not apply to it. The contextual menu button is what gets focus, and the patches here don't touch that.

From an accessibility viewpoint, I have no strong opinion about which patch from #79 is best. The simplest approach is 2994909-79-highlight-over-focus.patch. There is no actual accessibility need for the extra styles in the other patches, at least as far as WCAG is concerned. The hover border style is a secondary signifier only; the primary signifier for a pointer user is the pointer itself (mouse arrow icon, screen magnifier cross-hairs, or actual finger).

What I DO have strong opinions about:

  • .focus is a misleading class name for the container outline styling. (Doesn't affect the user, but has made it hard to comprehend the comments here. That's a DX issue.)
  • The focus styling for the contextual menu button fails "Use of Color" (WCAG 2.0), and the resting state fails "Non-text Contrast" (WCAG 2.1). Those are general problems for everywhere it is used, so I'll file a separate issue for this.
andrewmacpherson’s picture

Title: Highlight active element while working with dialogs in Layout Builder » [PP-1] Highlight active element while working with dialogs in Layout Builder
Status: Needs review » Postponed
Related issues: +#3037550: Clarify which block or section is being removed in layout builder dialog

Important related issue!

While I think that the highlight proposed here is helpful, it only helps sighted users. If we commit this issue on it's own, it will introduce a WCAG level A failure of "Info and relationships" because the only way you know what a remove block/section dialog refers to is by the visual highlight.

So we must not commit this issue, until after fixing:. #3037550: Clarify which block or section is being removed in layout builder dialog. I've made that a separate issue, because it's important for accessibility regardless of the highlight introduced here.

andrewmacpherson’s picture

Title: [PP-1] Highlight active element while working with dialogs in Layout Builder » Highlight active element while working with dialogs in Layout Builder
Status: Postponed » Needs review

The last submitted patch, 79: 2994909-79-highlight-over-focus.patch, failed testing. View results

Status: Needs review » Needs work

The last submitted patch, 79: 2994909-79-cx-focus-beats-highlight.patch, failed testing. View results

tedbow’s picture

Issue tags: +Needs reroll
tedbow’s picture

After meeting with UX team on Tuesday it was decided that the 2994909-79-highlight-over-focus.patch patch was the way to go from #79.

so only that patch needs a reroll.

The UX team also suggested we make a non-stable blocking follow-up Explore ways to make the highlighted Layout Builder element stand out more. This could be tricky because it is displayed in different front-end themes. So it might end up being just recommendation in the theming guide for Layout Builder.

lauriii’s picture

I tried to improve the design a bit from the black border.

Add section:

Highlighted add section:

Block:

Highlighted block:

Add block:

Highlighted add block:

Section with blocks:

Highlighted section with blocks:

Status: Needs review » Needs work

The last submitted patch, 97: 2994909-97.patch, failed testing. View results

tedbow’s picture

Status: Needs work » Needs review
FileSize
27.79 KB
2.7 KB

@lauriii do you know what patch you started with if so I can make interdiff. I chatted with @lauriii and he said he only made CSS changes but want to confirm again with him.

  1. +++ b/core/modules/layout_builder/css/layout-builder.css
    @@ -122,3 +123,32 @@
    +  background: rgba(47, 145, 218, 0.05);
    

    Since #2938182: Design intuitive affordances for Layout Builder (for illustrating which parts of the page are editable in a given context) added a white background to the layout builder we are able now to actually do a background for the highlighted block too.

  2. +++ b/core/modules/layout_builder/js/layout-builder.es6.js
    @@ -201,4 +201,74 @@
    +          'is-layout-builder-highlighted',
    

    The class now here was changed from 'layout-builder-highlight' which is why the test failed.

    I just was want to make sure this was intentional. Seems good to me.

  3. +++ b/core/modules/layout_builder/tests/src/FunctionalJavascript/LayoutBuilderUiTest.php
    @@ -116,4 +125,165 @@ protected function assertModifiedLayout($path) {
    +  private function assertHighlightedProperlyOutlined() {
    +    $outline = $this->getSession()->evaluateScript("window.getComputedStyle(document.getElementsByClassName('layout-builder-highlight')[0],null).getPropertyValue('outline')");
    +    $this->assertEquals('rgb(0, 0, 0) solid 3px', $outline);
    +  }
    

    This will also cause a fail since the actual styling has changed. I doubt we need to do this.

    I don't think anywhere has in core we check that when apply a class it has certain style properties;

    I removed it. If we wanted to keep it it would have be different based on whether it is block or "add section" or "add block" now since they are different.

lauriii’s picture

FileSize
6.01 KB

I used 2994909-79-highlight-over-focus.patch as a base for my patch in #97. Here's interdiff.

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

Drupal 8.7.0-alpha1 will be released the week of March 11, 2019, which means new developments and disruptive changes should now be targeted against the 8.8.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

GrandmaGlassesRopeMan’s picture

Status: Needs review » Needs work
  1. +++ b/core/modules/layout_builder/js/layout-builder.es6.js
    @@ -201,4 +201,74 @@
    +      $('.is-layout-builder-highlighted').removeClass('is-layout-builder-highlighted');
    

    This should be split to a new line. Check Prettier.

  2. +++ b/core/modules/layout_builder/js/layout-builder.es6.js
    @@ -201,4 +201,74 @@
    +    mainCanvas.addEventListener('transitionend', () => {
    

    This event, `transitionend`, can this be name-spaced? I am not sure where/what is triggering this event.

  3. +++ b/core/modules/layout_builder/js/layout-builder.es6.js
    @@ -201,4 +201,74 @@
    +        const targetTop = $target.offset().top;
    +        const targetBottom = targetTop + $target.outerHeight();
    +        const viewportTop = $(window).scrollTop();
    +        const viewportBottom = viewportTop + $(window).height();
    

    These are all numbers?

  4. +++ b/core/modules/layout_builder/js/layout-builder.es6.js
    @@ -201,4 +201,74 @@
    +      $('.is-layout-builder-highlighted').removeClass('is-layout-builder-highlighted');
    

    This should be split to a new line. Check Prettier.

xjm’s picture

Can we get animations of the latest behavior with the final design and embed them in the IS? Thanks!

bnjmnm’s picture

Issue summary: View changes
Status: Needs work » Needs review
FileSize
21.57 KB
21.83 KB
3.49 KB
27.82 KB

re #102

  1. Ran prettier, new line added.
  2. The transitionend event is a standard DOM event that is triggered at the end of a CSS transition.
  3. These are all numbers?

    I double checked that height, scrollTop, outerHeight, and offset().top return numbers.

  4. Ran prettier, new line added.

Additional things:

  1. For the functionality that scrolls the highlighted element into view, I discovered that IE does not accept scrollBy() with an object as the first arg, but it does accept scrollBy(x-coord, y-coord). The options object is desirable when available (it provides the option to scroll smoothly instead of instantly - the default in some browsers), but not critical, so I added a check that uses scrollBy(options) when compatible, but uses scrollBy(x-coord, y-coord) otherwise. Here is a video of IE11 using scrollBy(x-coord, y-coord) https://youtu.be/0hkVsas8blM
  2. The highlights for Configure Section resulted in two borders around the highlighted section. Made a small CSS change to eliminate this doubling.
    Before:

    After:
  3. Per #103, recorded a video with the current behavior and added it to the issue summary https://youtu.be/r2UlWDmuAxY
tim.plunkett’s picture

GrandmaGlassesRopeMan’s picture

I guess I should have mentioned that the changes look good to me. 🎉

lauriii’s picture

tedbow’s picture

Status: Needs review » Needs work

At UX meeting today there was unanimous that we switch back to highlight border colors that we had in before the changes in #97.

So this would mean always black border around highlighted elements not matter if they are new/existing block or section.

So this would just mean that

+++ b/core/modules/layout_builder/css/layout-builder.css
@@ -122,3 +123,32 @@
+  background: rgba(47, 145, 218, 0.05);

And we the consensus was that we remove the background change for blocks.

Since there were other JS and class name changes in #97 I don't think we can got back previous patches just need to update CSS for the new black border on highlighted elements.

tedbow credited jrockowitz.

tedbow credited rainbreaw.

tedbow credited webchick.

tedbow’s picture

crediting those from UX meeting who wasn't already credited.

Let me know if I missed anyone

tedbow’s picture

Status: Needs work » Needs review
FileSize
1.44 KB
27.72 KB

Ok implementing the UX meeting recommendations re #108

Going to file 2 follow ups:

  1. When you click "Add section" the ajax progress throbber briefly changes the height briefly
  2. Determine if it is possible for the "Configure Section" highlight completely hide the dotted border it replaces.

Status: Needs review » Needs work

The last submitted patch, 114: 2994909-114.patch, failed testing. View results

xjm credited benjifisher.

xjm credited ckrina.

xjm’s picture

Adding a couple other contributors from the UX meeting.

xjm’s picture

I manually tested and confirmed this addresses the usability and accessibility feedback we received during the UX meeting yesterday. Nice work!

xjm’s picture

I reviewed the docs and backend code. Just a bunch of docs nitpicks, mostly regarding small words like "the" and "is" being omitted from inline comments.

  1. +++ b/core/modules/layout_builder/js/layout-builder.es6.js
    @@ -201,4 +201,85 @@
    +       * Every dialog has a single 'data-layout-builder-target-highlight-id'
    +       * attribute.
    +       * Every dialog-opening element has a unique
    +       * 'data-layout-builder-highlight-id' attribute.
    

    This formatting is a bit weird; I think we can combine these two half-paragraphs?

  2. +++ b/core/modules/layout_builder/js/layout-builder.es6.js
    @@ -201,4 +201,85 @@
    +       * an elements value of data-layout-builder-highlight-id, the class
    

    Should this be "an element's value"?

  3. +++ b/core/modules/layout_builder/js/layout-builder.es6.js
    @@ -201,4 +201,85 @@
    +       * 'is-layout-builder-highlighted' is added to it.
    

    "Added to the element", I think. (As the sentence is currently written, "it" refers to the data attribute rather than the element itself.)

  4. +++ b/core/modules/layout_builder/js/layout-builder.es6.js
    @@ -201,4 +201,85 @@
    +   * When a Layout Builder dialog is triggered, the main canvas resizes. After
    +   * the resize transition is complete, see if target element is still visible
    +   * in viewport. If not, scroll page so target element is again visible.
    

    Nit: the word "the" is missing twice here ("the target element").

  5. +++ b/core/modules/layout_builder/js/layout-builder.es6.js
    @@ -201,4 +201,85 @@
    +        // These four variables are used to determine if element in viewport.
    

    "If the element is in the viewport".

  6. +++ b/core/modules/layout_builder/js/layout-builder.es6.js
    @@ -201,4 +201,85 @@
    +        // If element not in viewport, scroll it into view.
    

    "If the element is not in the viewport"

  7. +++ b/core/modules/layout_builder/js/layout-builder.es6.js
    @@ -201,4 +201,85 @@
    +          // Check if browser supports scrollBy(options) if not, use
    

    "Check whether the browser supports scrollBy(options). If it does not, use..."

  8. +++ b/core/modules/layout_builder/js/layout-builder.es6.js
    @@ -201,4 +201,85 @@
    +  // When a dialog closes, remove highlight from all elements.
    

    "Remove the highlight".

  9. +++ b/core/modules/layout_builder/src/LayoutBuilderHighlightTrait.php
    @@ -0,0 +1,64 @@
    +   *   The region within the section the block is placed.
    

    This isn't quite a sentence... maybe "The section region in which the block is placed"?

  10. +++ b/core/modules/layout_builder/tests/src/FunctionalJavascript/LayoutBuilderUiTest.php
    @@ -116,4 +125,153 @@ protected function assertModifiedLayout($path) {
    +   * Tests that dialog opening elements are properly highlighted.
    

    Nit: "dialog-opening elements", or, better, "elements that open the dialog".

  11. +++ b/core/modules/layout_builder/tests/src/FunctionalJavascript/LayoutBuilderUiTest.php
    @@ -116,4 +125,153 @@ protected function assertModifiedLayout($path) {
    +    // Highlight is present with AddSectionController.
    ...
    +    // Highlight is present with ChooseBlockController::build().
    ...
    +    // Highlight is present with ChooseBlockController::inlineBlockList().
    

    "The highlight is..."

  12. +++ b/core/modules/layout_builder/tests/src/FunctionalJavascript/LayoutBuilderUiTest.php
    @@ -116,4 +125,153 @@ protected function assertModifiedLayout($path) {
    +    // Submit form to add section then confirm no element highlighted.
    

    "Submit the formm to add the section and then confirm that no element is highlighted anymore."

  13. +++ b/core/modules/layout_builder/tests/src/FunctionalJavascript/LayoutBuilderUiTest.php
    @@ -116,4 +125,153 @@ protected function assertModifiedLayout($path) {
    +    // Add custom block.
    

    "Add a custom block."

  14. +++ b/core/modules/layout_builder/tests/src/FunctionalJavascript/LayoutBuilderUiTest.php
    @@ -116,4 +125,153 @@ protected function assertModifiedLayout($path) {
    +    // Highlight should persist with all block config dialogs.
    

    "The highlight should..."

  15. +++ b/core/modules/layout_builder/tests/src/FunctionalJavascript/LayoutBuilderUiTest.php
    @@ -116,4 +125,153 @@ protected function assertModifiedLayout($path) {
    +    // Highlight is present with ConfigureBlockFormBase::doBuildForm.
    

    "The highlight is..." Also, doBuildForm() should have parens.

  16. +++ b/core/modules/layout_builder/tests/src/FunctionalJavascript/LayoutBuilderUiTest.php
    @@ -116,4 +125,153 @@ protected function assertModifiedLayout($path) {
    +    // Highlight is present when Configure section dialog open.
    
    The highlight is present when the "Configure section" dialog is open.
  17. +++ b/core/modules/layout_builder/tests/src/FunctionalJavascript/LayoutBuilderUiTest.php
    @@ -116,4 +125,153 @@ protected function assertModifiedLayout($path) {
    +    // Highlight is present when Remove section dialog open.
    
    The highlight is present when the "Remove section" dialog is open.
  18. +++ b/core/modules/layout_builder/tests/src/FunctionalJavascript/LayoutBuilderUiTest.php
    @@ -116,4 +125,153 @@ protected function assertModifiedLayout($path) {
    +    // Block is highlighted when its "Configure" contextual link is clicked.
    ...
    +    // Block is highlighted when its "Remove block" contextual link is clicked.
    

    "A block is..."

  19. +++ b/core/modules/layout_builder/tests/src/FunctionalJavascript/LayoutBuilderUiTest.php
    @@ -116,4 +125,153 @@ protected function assertModifiedLayout($path) {
    +    // Make sure highlight remains when mouse reveals contextual links.
    

    "Make sure the highlight remains when contextual links are revealed with the mouse."

  20. +++ b/core/modules/layout_builder/tests/src/FunctionalJavascript/LayoutBuilderUiTest.php
    @@ -116,4 +125,153 @@ protected function assertModifiedLayout($path) {
    +    // @todo: Remove reload after https://www.drupal.org/node/2918718 completed.
    

    @todo Remove the reload once https://issue is completed.

  21. +++ b/core/modules/layout_builder/tests/src/FunctionalJavascript/LayoutBuilderUiTest.php
    @@ -116,4 +125,153 @@ protected function assertModifiedLayout($path) {
    +   * Confirm presence of is-layout-builder-highlighted element.
    

    "Confirms the presence of the 'is-layout-builder-highlighted' class."

  22. +++ b/core/modules/layout_builder/tests/src/FunctionalJavascript/LayoutBuilderUiTest.php
    @@ -116,4 +125,153 @@ protected function assertModifiedLayout($path) {
    +   * Waits for dialog to close and confirms no highlights present.
    

    "Waits for the dialog to close and confirms no highlights are present."

tedbow’s picture

Status: Needs work » Needs review
FileSize
13.96 KB
32.45 KB

In #114 \Drupal\Tests\layout_builder\FunctionalJavascript\LayoutBuilderDisableInteractionsTest::assertContextualLinkRetainsMouseup() failed because it checks that mouse up events are working correctly by moving the mouse after using the contextual link on the body field and making sure the body field is in exactly the same place. This is because if the mouseup event is not working correctly than the body field would actually dragged when the mouse moved.

The problem is with our new border JS getBoundingClientRect() of the element will change by 4 pixels(the exact difference in the fail). We could change assert to take these 4 pixels into account but this seems we would be just asking for random fails if we measure to the exact pixel.

Instead I changed the assert to take into account that the body might move very slightly but it should be much much less than the distance the mouse is move(because it is not moving because the mouse moved).

Please read he comments in the interdiff on core/modules/layout_builder/tests/src/FunctionalJavascript/LayoutBuilderDisableInteractionsTest.php for more detailed explanation of the assert logic but it finally comes down to this assert.
$this->assertGreaterThan($distance_body_block_moved * 20, $minimum_distance_mouse_moved);
In assertGreaterThan() the 2nd should be greater.

RE #120 @xjm thanks for the review. Fixed all the nits 🔎

tim.plunkett’s picture

The doc fixes look good.

I like the test change and the new method. One nit:

+++ b/core/modules/layout_builder/tests/src/FunctionalJavascript/LayoutBuilderDisableInteractionsTest.php
@@ -253,14 +254,43 @@ protected function assertContextualLinkRetainsMouseup() {
+    $new_body_block_bottom_position = $this->getElementVerticalPosition($body_field_selector, 'bottom');
+    $iframe_top_position = $this->getElementVerticalPosition('#iframe-that-should-be-disabled');
...
+    $new_body_block_top_position = $this->getElementVerticalPosition($body_field_selector);
...
+   * @param string $position_type
+   *   The position type to get, either 'top' or 'bottom'.
...
+  protected function getElementVerticalPosition($css_selector, $position_type = 'top') {

I think the default value should be removed and used explicitly in the method calls. If you disagree, can you expand the @param doc to mention the default value?

tedbow’s picture

@tim.plunkett thanks for review. fixed

tim.plunkett’s picture

Status: Needs review » Reviewed & tested by the community

Thanks!
As of #119 this has no more signoffs needed, #120 is addressed by #121, and the patch on the whole looks great!

lauriii’s picture

Status: Reviewed & tested by the community » Needs work
  1. +++ b/core/modules/layout_builder/css/layout-builder.css
    @@ -121,3 +122,22 @@
    +.layout-builder-block.is-layout-builder-highlighted,
    ...
    +  margin: -4px -2px;
    

    It would be great if we didn't change the margin of the .block element since it is not a layout builder element.

    Discussed with @tim.plunkett on a call and he proposed that we wrap blocks in the layout builder preview with another div that we could theme more safely. I think that is a good solution for fixing this problem.

  2. +++ b/core/modules/layout_builder/js/layout-builder.es6.js
    @@ -201,4 +201,86 @@
    +    // This event fires when canvas css transitions are complete.
    

    s/css/CSS

tim.plunkett’s picture

Status: Needs work » Reviewed & tested by the community
FileSize
32.46 KB
698 bytes

1) Attempted using a wrapper but that interfered with contextual links.
I opened #3042216: Only add .layout-builder-block to blocks when in the Layout Builder UI to discuss changing how that is done.

2) Fixed!

Marking RTBC for the capitalization fix

  • lauriii committed 40d6aca on 8.8.x
    Issue #2994909 by bnjmnm, tedbow, kostyashupenko, tim.plunkett, lauriii...

  • lauriii committed d1b0967 on 8.7.x
    Issue #2994909 by bnjmnm, tedbow, kostyashupenko, tim.plunkett, lauriii...
lauriii’s picture

Version: 8.8.x-dev » 8.7.x-dev
Status: Reviewed & tested by the community » Fixed
FileSize
889 bytes

I'm fine with postponing #125.1 to a follow-up. We do other modifications to the spacing in the layout builder preview as well, and the worst case scenario is that someone experiences different margin between blocks. This shouldn't render the site unusable or nothing of the sort.

I've manually tested the changes on Chrome, Firefox and IE 11 (normal and high contrast mode) and I couldn't find any regressions on either Umami or Bartik.

I've got a backend signoff from @xjm in #120. I also recognized #91 as a sign-off from accessibility topic maintainer since we've already solved the related issues.

There was an extra new line that was caught by PHPCS. I fixed this on commit and attached an interdiff.

Committed 40d6aca and pushed to 8.8.x. Also cherry-picked to 8.7.x. Thanks!

Status: Fixed » Closed (fixed)

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