Problem/Motivation

As of 2432c02138861423b7db36526554afcacee0bc46 at least.

Steps to reproduce.

  1. Navigate to an article.
  2. Enable quick edit.
  3. Activate the body field and change the text.
  4. Save the changes.
  5. Open the contextual links on the entity and note that three quick edit links are now present.

Proposed resolution

unknown.

API changes

none.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

jessebeach’s picture

Issue tags: +sprint, +Spark

adding tags.

jessebeach’s picture

An illustration of the issue.

A screenshot of the the contextual links on a node entity. The link menu is open. Instead of one link to quick edit the node, three links exist, two of which are duplicates.

Wim Leers’s picture

Status: Active » Postponed

Hrm. A new ContextualLinkView must be instantiated whenever a modified field is inserted… This should be pretty easy to fix :)

If I work on fixing this now, I fear that will conflict with #1678002: Edit should provide a usable entity-level toolbar for saving fields? Let's fix this after that.

Wim Leers’s picture

Status: Postponed » Closed (cannot reproduce)
Issue tags: -sprint
TechNikh’s picture

Status: Closed (cannot reproduce) » Active
FileSize
100.52 KB

I can reproduce. screenshot is attached.

Wim Leers’s picture

#5: Could you then please provide steps to reproduce? :)

jessebeach’s picture

Definitely, any tips to reproduce it will help us track down the conditions for the bug!

jessebeach’s picture

Issue tags: +sprint

adding a sprint tag.

jessebeach’s picture

Looking into this...

TechNikh’s picture

http://drupal8.drool4drupal.com/drupal/node/1 shows quick edit in contextual links twice.
http://drupal8.drool4drupal.com/drupal/node/49 shows only once

I don't know how these node are different from each other
I am guessing, it will be fixed if I clear cache.

for testing, I have given anonymous user access to edit nodes on my server.

jessebeach’s picture

I bet this is related. We have a contextual link trigger without any contextual links.

Screenshot of the front page of a Drupal site. The login block has a contextual link trigger without any contextual links listed.

jessebeach’s picture

I added #2049601: Contextual links present an empty links trigger when no link items are available for an entity to deal with the empty contextual links, but I wasn't able to reproduce that issue today, so that side issue is postponed pending more input.

For the duplicated and triplicated "quick edit" links, the solution ended up being quite simple. We have a callback that inserts the quick edit link into the contextual links after a trip to server to get metadata about the link's entity and fields. The response to that request contains one or more insert commands for injecting JS data onto the page. The callback to insert the contextual link is invoked within the success callback to the AJAX request for metadata. If more than one insert command is returned, we get N quick links, where N equals the number of insert commands.

To fix this, I wrapped the contextual link insert callback in underscores _.once() utility. It creates a function wrapper that can only be invoked once. All subsequent calls are no-op. So we get exactly one links now per entity.

Steps to reproduce

  1. Create an article node with an image, tag and body text.
  2. View the node.
  3. Click on the contextual link trigger. It should have two "quick edit" links.

@TechNikh, can you verify the resolution?

TechNikh’s picture

Thanks jessebeach. I applied the above patch and http://drupal8.drool4drupal.com/drupal/index.php/node/1 shows quick edit link once.

TechNikh’s picture

Status: Active » Needs review

changing status for automatic tests.

Wim Leers’s picture

Status: Needs review » Needs work

I wanted to review this patch and hopefully RTBC it, but it seems I can no longer reproduce the problem. I followed the steps to reproduce in the issue summary.

Can anybody else still reproduce it? If so, please update the steps to reproduce.

jessebeach’s picture

Status: Needs work » Postponed (maintainer needs more info)

Ugh, now I can't reproduce it either. Not good. Not good. I don't like when things change and resolve without direct intervention. I'm marking this issue as postponed. I'm not yet convinced that this issue won't resurface.

Wim Leers’s picture

Status: Postponed (maintainer needs more info) » Closed (cannot reproduce)
Issue tags: -sprint

A month later, zero such reports, and zero times been able to reproduce it. So: closing :)

Wim Leers’s picture

Same issue has popped up again, now reliably reproducible: #2089397: Double "Quick edit" contextual link.

swentel has taken the patch in #12 and moved it over there. It still fixes the problem :)

I RTBC'd the patch there.