Problem/Motivation

Contextual.module's contextual link triggers don't work well when they're nested.

There's two aspects:

  1. the superficial problems, as outlined in #2 and further explained in #6 — fixed by the patch in #6, also see #6 for a brief before-after screencast. Note that this was probably a regression of #1216776: Two nested contextual links regions are active, when the outer region is hovered..
  2. the greater problem/root cause: contextual links not being consciously designed for nested usage

The greater problem is present in both Drupal 7 & 8:
nested contextual links D7 - hover.png
nested contextual links D8.png

Proposed resolution

TBD

Remaining tasks

TBD

User interface changes

TBD

API changes

None, probably.

#1216776: Two nested contextual links regions are active, when the outer region is hovered.

Original report by Gábor Hojtsy

NOW SEE #1949946: Do user testing of contextual toggle for in-place editing for this, as per #4.

Problem

#1874664: Introduce toolbar level "Edit" mode that shows all contextual links introduces a great new integrated interaction model that needs more eyes to look at it, not only the few people who cared to work on it and iterate on several designs to completion.

Proposal

Do more user testing on the changes introduced in #1874664: Introduce toolbar level "Edit" mode that shows all contextual links especially with other related changes proposed.

CommentFileSizeAuthor
#53 contextual-move-overlapping-gears-1914966-53.patch2.13 KBrhristov
#46 2015-07-30 16_31_31-Who we are _ Bield.png3.96 KBrkent_87
#46 2015-07-30 16_31_16-Who we are _ Bield.png4.39 KBrkent_87
#44 gears-three-levels.png23.03 KBsirtet
#44 contextual-move-overlapping-gears-1914966-44.patch1.21 KBsirtet
#2 edit-page-reload-with-opened-inspector.png105.7 KBoresh
#2 edit-popup-overlay.png49 KBoresh
#3 Screen Shot 2013-03-20 at 16.46.21.png18.63 KBWim Leers
#8 nested contextual links D8.png4.1 KBWim Leers
#6 nested-contextual-links-1914966-6.patch1.54 KBWim Leers
#6 nested contextual links - after.mov_.zip442.01 KBWim Leers
#6 nested contextual links - before.mov_.zip343.36 KBWim Leers
#6 nested contextual links D7 - click.png5.58 KBWim Leers
#6 nested contextual links D7 - hover.png4.11 KBWim Leers
#11 slightly less hacky proposed solution.mov_.zip1.36 MBWim Leers
#11 hacky proposed solution.mov_.zip1.66 MBWim Leers
#14 interdiff.txt2.17 KBWim Leers
#14 nested-contextual-links-1914966-14.patch3.42 KBWim Leers
#15 interdiff_14-to-15.txt1.23 KBjessebeach
#15 nested-contextual-links-1914966-15.patch4.1 KBjessebeach
#18 Screen Shot 2013-04-03 at 12.07.57 PM.png21.28 KBwebchick
#25 nested-contextual-links-d7-backport-1914966.patch2.83 KBlcampanis
#26 nested-contextual-links-d7-backport-1914966.patch2.83 KBlcampanis
#27 nested-contextual-links-d7-backport-1914966-27.patch2.8 KBdrclaw
#28 nested-contextual-links-d7-backport-1914966-28.patch2.73 KBdrclaw
#40 before.png13.96 KBDavid_Rothstein
#40 after.png14.41 KBDavid_Rothstein
#41 no-gears-overlap.png32.84 KBsirtet
#41 gears-overlap.png33.82 KBsirtet
#41 list-of-views-view.txt4.24 KBsirtet
#41 contextual-move-overlapping-gears-1914966-41.patch1.21 KBsirtet
#43 Contextual menu patch test view with no title.png89.32 KBBegun
#43 Contextual menu patch test view with title.png47.88 KBBegun
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Wim Leers’s picture

Component: other » contextual.module

.

oresh’s picture

There are actually a lot of bugs there.

If you create a view with show content: full content, you'll get two or more (depending on row quantity) edit buttons, which cause this bugs:
1. if you click on the view's edit button, it can be under the the edit of the first row (image 1)
2. if you have no title for the view - first row's edit can cover the view's edit, so you can't get to it.
3. if you click on the row's edit button:
3_a. it will trigger the dropdown of the parent edit button in the same time
3 _b. if you unhover and try to click the view's edit button, it will appear for a split second and the disappear.
4. if you open element inspector in chrome (tested on v.24 on Ubuntu) and reload the page with inspector opened, you'll trigger all the edit links to be visible (image 2).
4_a. clicking the edit in toolbar in this case does nothing
4_b. if you click any edit button and hover a link in dropdown - it won't get a background image

Though enabling editing by clicking the button in the upper toolbar fixes some issues (3b).

Tested on Chrome v.24 on Ubuntu
I think most of this behaviors is present on other browsers.

Wim Leers’s picture

Assigned: Unassigned » Wim Leers
Issue tags: +sprint
FileSize
18.63 KB

Problem reproduced:
Screen Shot 2013-03-20 at 16.46.21.png

I'll fix this tomorrow.

Gábor Hojtsy’s picture

I've opened #1949946: Do user testing of contextual toggle for in-place editing which can be used to keep the original purpose of this issue. So we can retitle and resummarize this issue for the bugs.

Gábor Hojtsy’s picture

Title: Do more user testing of contextual toggle and integrated in-place editing » Bugs with contextual menu pencils
Category: task » bug

Retitled for current scope.

Wim Leers’s picture

Title: Nested contextual links triggers don't work well » Nested contextual links don't work well
FileSize
1.54 KB
442.01 KB
343.36 KB
5.58 KB
4.11 KB

I can reproduce everything described in #2, with the exception of step 4: the pencil icons appearing upon reloading the page with Chrome's inspector open.

The root cause for this is that contextual.module has never actually (AFAICT) been consciously designed to work with nested contextual regions. I.e., this particular problem also exists in the Drupal 7 implementation:

nested contextual links D7 - hover.png
nested contextual links D7 - click.png

So, I can solve the particular problems at hand here, but what we should really do is truly think through how to make nested contextual links work well. Because the Drupal 8 front page may now be a View, but it's a View with a title, which causes the contextual links trigger for the view to be rendered higher than the contextual links trigger for the node it contains. However, imagine it without a title like the Drupal 7 example above, and you again have the same problem:

nested contextual links D8.png

Here's a patch that fixes the direct interaction problems described in #2. Before and after screencasts (10 seconds each) attached (compressed in .zip files because it would otherwise not be accepted by d.o).

Wim Leers’s picture

Title: Bugs with contextual menu pencils » Nested contextual links triggers don't work well
Priority: Normal » Major
Status: Active » Needs review
Wim Leers’s picture

Image that I'm adding to #6.

Wim Leers’s picture

Title: Nested contextual links don't work well » Nested contextual links triggers don't work well

Bojhan pointed out that the problems in #2 appear to be a regression of #1216776: Two nested contextual links regions are active, when the outer region is hovered.. Already included in the updated issue summary.

effulgentsia’s picture

Issue tags: +VDC

the greater problem/root cause: contextual links not being consciously designed for nested usage

Tagging VDC, because node teasers within a View is a common use case and affects the majority of D7 sites too. With Views in D8 core, we need to decide to either not add contextual links to views, or consciously design contextual links for nested usage.

Wim Leers’s picture

After talking to Bojhan and yoroy about this, it seems the only way to solve this is by automatically inserting an offset when appropriate. It's the "when appropriate" part that is tricky. A 10-second screencast of the simplest solution I could think of (yet still hacky) is attached as "hacky proposed solution".

Do we *really* want to calculate whether the two container divs are at the same position on the screen (the same "offset")? If we do, then the result looks less annoying (because it only makes changes when it's really needed). Another 10-second screencast demonstrates this, which is slightly more complex code wise, but looks less hacky, attached as "slightly less hacky proposed solution".

yoroy, Bojhan and I agreed that we'd only check for *two*, not *n* "nested contextual links that happen to have overlapping tops for their contextual regions".

Bojhan’s picture

I think we should go with the less hacky, primarily because we don't want non-problematic contextual links to move around. You should probally check how this behaves when there are many contextual links on the page.

yoroy’s picture

The less hacky one indeed because it doesn't affect non-nested contextual links.

Wim Leers’s picture

Alright, #11 implemented based on feedback in #12 & #13.

This patch now addresses all problems raised, including the broadened problem scope introduced in #6, after solving the initial problem.

jessebeach’s picture

I made insignificant coding standard and comment changes (see the interdiff). Otherwise this patch is good to go.

jessebeach’s picture

Status: Needs review » Reviewed & tested by the community

Bot says green and my changes were insignificant, so I'm going to mark this as RTBC.

Wim Leers’s picture

Thanks, good changes!

webchick’s picture

Status: Reviewed & tested by the community » Fixed
FileSize
21.28 KB

While testing this I ran into a situation where more than two levels of nesting were required:

Two contextual links overlapping, a third one below.

This is a the front page view, exposed as a block, showing a node inside. The two overlapping ones are a contextual link for Views (edit view) and a contextual link for blocks (Configure block).

However, discussing w/ Alex and xjm, this isn't really the fault of this patch; Views should be doing what Menu module does and combining its own contextual link into the one from the Block, in which case 2 levels of nesting that this patch checks for would be sufficient.

We also found some really funky "flicker" behaviour with contextual links as a part of testing this patch, but since it's an existing bug in HEAD, we'll file an issue (and video!) separately for that.

So given that this patch does what it says it does, committed and pushed to 8.x. Thanks!

webchick’s picture

Issue tags: +Needs followup

Let's get a follow-up issue for that views bug, and a follow-up for the "flicker" (if it doesn't already exist).

webchick’s picture

Wim Leers’s picture

Issue tags: -sprint
xjm’s picture

So I can't reproduce what's in the screenshot in #18. However, I can confirm that the "Edit view" contextual link never appears in the block contextual links. I'm guessing mine are overlapping entirely and @webchick's were overlapping only partially.

The only VDC issues related to contextual links that I find all seem to be unrelated:
#1933426: [Followup] Fix contextual links on views (followup for a previous JS fix)
#1877376: Change notice: Improve Views UI text for the contextual links display setting
#1933766: Move all contextual links code to views_ui module

effulgentsia’s picture

Issue tags: -Needs followup

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

Anonymous’s picture

Issue summary: View changes

Revamped issue summary.

lcampanis’s picture

Nice one guys!

I faced the same issue in D7 trying to render node entities using Views, inside a Bootstrap Carousel block (multiple sub-contextuals). The node edit menu would sit on top of the block configure menu.

The code will adjust the parent wrapper, and move down the sub-contextual wrappers.

Here is a D7 backport based on @jessebeach above: https://www.drupal.org/node/1914966#comment-7248342

lcampanis’s picture

FileSize
2.83 KB
drclaw’s picture

Thanks for the D7 backport @lcampanis! There is a console.log left behind, however. Attached patch is exactly the same, sans console.log.

drclaw’s picture

Oops. didn't get it all. This one should do it.

david_garcia’s picture

Works great! Thank you.

sirtet’s picture

Version: 8.0.x-dev » 7.x-dev
Status: Closed (fixed) » Needs review

Would be nice if D7 had this fixed too...
Patch #28 works for me on 7.28

PS:
Another working JS solution for that problem can be found on Stack Exchange:
http://drupal.stackexchange.com/questions/117719/css-fix-for-stacked-gea...

david_garcia’s picture

Status: Needs review » Reviewed & tested by the community

#28 working great for Drupal 7.

xjm’s picture

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 28: nested-contextual-links-d7-backport-1914966-28.patch, failed testing.

Status: Needs work » Needs review
david_garcia’s picture

Status: Needs review » Reviewed & tested by the community
Bojhan’s picture

Assigned: Wim Leers » Unassigned

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 28: nested-contextual-links-d7-backport-1914966-28.patch, failed testing.

Status: Needs work » Needs review
dcam’s picture

Status: Needs review » Reviewed & tested by the community
David_Rothstein’s picture

Status: Reviewed & tested by the community » Needs work
FileSize
13.96 KB
14.41 KB

I tested this patch and am seeing the nested contextual links become significantly misaligned, even when they don't overlap with each other at all... see screenshots below.

Also, this could probably use a more in-depth code review, since the code wound up looking pretty different from what went into Drupal 8.

Before patch:

After patch:

sirtet’s picture

I put the code from
http://drupal.stackexchange.com/questions/117719/css-fix-for-stacked-gea...
into a patch (i simply appended the code, which i guess is not really the correct drupal way).

This code leaves nested but non- overlapping gears alone, and moves them if they DO overlap.
It's less code, and far easyer to read.

For testing, i made a view with 2 blocks.
One with nested but non-overlapping links, one where the links overlap.
The overlap is created by removing the title, plus some css in the view's head, see it's export, list-of-views-view.txt

Screenshots taken with the patch applied:
no overlap
gears would overlap

sirtet’s picture

Status: Needs work » Needs review
Begun’s picture

Tested patch in #42 but encountered the following issue:

  • Contextual link menus lower in the page hierarchy are covered by ones further up.

In my case I have a panel page, which contains a contextual menu (links: "edit panel"). Within the panel page is a views pane, also with a contextual menu (link: "Edit view", "Order view"). The view lists nodes. Each node also has a contextual menu. If the View title is removed then the node contextual link is overlapped by the view panel contextual menu. I have attached two images on show what happens when the view title is present, and the other which shows the contextual links with out the view title present.

Would it make more sense to adjust the horizontal positioning of overlapping elements rather than the vertical position?

sirtet’s picture

The patch from #41 just worked with 1 level of nesting, just changing the if- to a while- statement should make it work with whatever depth. I tested it with three stacked gears.
three levels

Horizontal or vertical shifting makes no difference with the given problem. Which one would be better depends on the theme and the element's content, i think it's almost impossible to find a always perfectly good looking solution.

One thing to consider would be to also move gears which are only partially overlapping.

andrefy’s picture

It worked for me

rkent_87’s picture

I tried the patch from #43 but I'm still getting contextual links on top of each other.

e.g. If I mouse from the left and click, I get the node contextual menu

node menu

but if I move over from the right I get the view contextual menu

view menu

Edit: I can't see how to delete this post but I can put some CSS padding on the view to separate them.

azinck’s picture

#44 is working well for me -- thanks!

dasginganinja’s picture

#44 works for me!!

  • webchick committed 577a3ef on 8.3.x
    Issue #1914966 by Wim Leers, jessebeach: Fixed Nested contextual links...

  • webchick committed 577a3ef on 8.3.x
    Issue #1914966 by Wim Leers, jessebeach: Fixed Nested contextual links...

  • webchick committed 577a3ef on 8.4.x
    Issue #1914966 by Wim Leers, jessebeach: Fixed Nested contextual links...

  • webchick committed 577a3ef on 8.4.x
    Issue #1914966 by Wim Leers, jessebeach: Fixed Nested contextual links...
rhristov’s picture

#44 is not working for me. We are using bootstrap theme as base theme and the overlapping is still there.
I am attaching a new patch.

kingandy’s picture

Patch from #53 had no visible effect for me, #44 worked though.

For what it's worth we're using a custom Omega-derived theme.

osopolar’s picture

I had Mini-Panels config and Node (view/edit) gears icons overlapping each other and was not able to click the underlying icon. This little css fixed it for me:

.contextual-links-wrapper + .contextual-links-wrapper {
  margin-right: 3em;
}
droplet’s picture

Anyone able to upload a theme/site with the bug or adding a test?