Problem/Motivation

Create an article, add a custom block in header region and visit front page. The 'Quick edit' contextual link is not available for the article and the following error is reported by firebug:
DrupalBehaviorError: attach ; quickedit: entityElement.get(...) is undefined

Steps to reproduce

  • Create a new page
  • Create a custom block
  • Place custom block in the left sidebar
  • Open new page
  • Click pencil icon
  • Quick edit link will not appear
  • The browser's JS console logs "Uncaught DrupalBehaviorError: attach ; quickedit: Cannot read property 'getAttribute' of undefined"

Proposed resolution

Remaining tasks

User interface changes

API changes

Comments

jrockowitz’s picture

Issue summary: View changes

I added the steps needed to reproduce the issue.

There seems to something off with how the field ids are being found via the CSS selector but I am not sure what exactly is the going on in the processField(fieldElement) function.

I think the provided patch is just suppressing the issue and resulting in block and/or certain fields not being quick-editable.

wim leers’s picture

Kyna’s picture

Note, bug visible after cache clear.

berdir’s picture

Status: Closed (duplicate) » Active

It might be a symptom, but we are still seeing this with a version that has #2284917: In-place editing of custom blocks broken *again* (because attributes and contextual links of custom blocks are lost).

Maybe it is something that just happens on our site, because of different markup or something, but I still think that quickedit should not cause an error here, because that breaks JS completely on the affected page.

So re-opening, would be great to have at least the fix from above, or maybe something else, that logs an error that helps to track down what happens/is missing.

manuel garcia’s picture

Priority: Normal » Major

Just confirming this right now on HEAD.

I've tested this using stark theme, but it happens also with Bartik. You can see the error by setting up the a view with ajax pagination, and clicking on next on the pager.

This bug basically breaks ajax pagination, and I'd guess other things that rely on behavoiurs..

DrupalBehaviorError: detach:unload ; quickedit: fieldModel is undefined

droplet’s picture

Status: Active » Postponed (maintainer needs more info)

Can't reproduce the reported issue.

#5 looks like a different bug.

edwardchiapet’s picture

I had the same issue in a View using QuickEdit and an AJAX pagination, and the update to 7.x.1.3 fixed it for me. All the console errors noted by Manuel Garcia are now gone, and AJAX pagination is working flawlessly now.

wim leers’s picture

Status: Postponed (maintainer needs more info) » Closed (cannot reproduce)
moleculefff’s picture

This can also occur if you are rendering a node in a page template that does not

<?php echo page['content']?>

As it's missing the content div

rgpublic’s picture

Version: 8.0.x-dev » 9.x-dev
StatusFileSize
new570 bytes

I've created a more recent patch for Drupal 8.1.3. It also happens for me when my template doesn't include $page['content'] but renders the fields more specifically - but hey, that's what templates are for, aren't they? So, I think this simple patch should be included with Drupal core. This will avoid ugly unnecessary errors in these cases since quickedit is working great otherwise.

berdir’s picture

Version: 9.x-dev » 4.0.0
Status: Closed (cannot reproduce) » Needs review
berdir’s picture

Version: 4.0.0 » 8.1.x-dev
agoradesign’s picture

absolutely agree with rgpublic. It is so damn easy to trigger this error. The patch makes quickedit far more fault tolerant!

phjou’s picture

I have reproduced this error with a node which has a field reference to a custom block. When the block is rendered, the "TypeError: entityElement.get(...) is undefined" is triggered.
I think that quickedit being more tolerant is a good idea.

manuel garcia’s picture

StatusFileSize
new570 bytes

Here is a patch that applies properly to 8.1.x

phjou’s picture

Thanks Manuel, the patch works again :)

heddn’s picture

Status: Needs review » Needs work

While this fixes the problem, it is missing comments.

wolffereast’s picture

Version: 8.1.x-dev » 8.2.x-dev
Status: Needs work » Needs review
StatusFileSize
new747 bytes

Re rolled the patch from 15 against 8.2.x and added an initial stab at some descriptive comments.

manuel garcia’s picture

Status: Needs review » Reviewed & tested by the community

Comment looks clear enough for me, taking the leap and marking it as RTBC.

wim leers’s picture

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

We can now actually have test coverage for this to prevent this from ever breaking again. So let's do that.

Benia’s picture

Passed in 8.2.0 and 8.2.1.

Benia’s picture

Can more people please test this? So needed in 8.2.4...

wim leers’s picture

Title: DrupalBehaviorError: attach ; quickedit: entityElement.get(...) is undefined » [PP-1] DrupalBehaviorError: attach ; quickedit: entityElement.get(...) is undefined
Status: Needs work » Postponed

Once #2828528: Add Quick Edit Functional JS test coverage is in, we have a solid foundation to write more functional JS tests. That will make addressing #20 a lot easier. We should be able to just codify the STR. Unfortunately, that means blocking this issue.

@Benia: we don't need more manual testing. We need automated testing.

manuel garcia’s picture

Thanks @Wim Leers for that, had a brief look at the patch, it will indeed make testing this far easier

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.6 was released on February 1, 2017 and is the final full bugfix release for the Drupal 8.2.x series. Drupal 8.2.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.3.0 on April 5, 2017. (Drupal 8.3.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.3.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

berdir’s picture

Status: Postponed » Closed (duplicate)

Duplicate of #2551373: contextual.js and quickedit.js should fail gracefully, with useful error messages, when Twig templates forget to print attributes and there's at least one more I think. Also, @catch there said that we don't need automated test coverage for it, as creating this scenario would be pretty complex and not worth it.