After installing Beta 4 I am finding that many node edit forms are broken, with the Yoast dialogue appearing above instead of below the form. In addition, CKEditor is also broken and does not load.

Console reports the following error;

Uncaught TypeError: Cannot read property 'addEventListener' of null
js_CA96T1_m2RdVe313r273VuPXqBkzRPBo_Zt_IKzrOFY.js:1398 

The error message seems to point at line 1398 of the js file file
document.getElementById(source).addEventListener("blur", listener)

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

MrPaulDriver created an issue. See original summary.

robertragas’s picture

Hello Paul,

Can I ask which version of the metatag module u have and could you try updating it?
Not sure if it would be the problem to your issues but I know many problems arise when the module version is too low.

MrPaulDriver’s picture

Hi Robert, metatag was one version behind but after updating and clearing caches the problem remains

gstout’s picture

Priority: Normal » Major

confirming identical behavior for us

gstout’s picture

Confirming I am an ass. :)

This is a caching error on our end. Worked in dev but our cdns where sitting on old js files making it not work on our live setup which has CDNs

That said this function in yoast_seo.js did cause a fatal error and break CKEditor until I add the null check.

/**
 * Parses the input in snippet preview fields on input evt to data in the metatag and path fields
 * @param source
 * @param target
 */
YoastSEO_DrupalSource.prototype.parseSnippetData = function(source, target) {
  var listener = function ( ev ) {
    // textContent support for FF and if both innerText and textContent are
    // undefined we use an empty string.
    document.getElementById(target).value = (ev.target.value || "");
    this.triggerEvent(target);
  }.bind(this);
  if(document.getElementById(source)) { // added this
    document.getElementById(source).addEventListener("blur", listener);
  } //added this
};

Hope this helps you @MrPaulDriver

gstout’s picture

Priority: Major » Normal
DamienMcKenna’s picture

Status: Active » Closed (works as designed)

The JS problem should have been fixed by #2784549: Views Improvements.

vensires’s picture

Title: Beta 4 breaks node edit forms » Breaks JS scripts on node edit forms
Version: 7.x-1.0-beta4 » 7.x-1.x-dev
Status: Closed (works as designed) » Active

The JS problem is still present in both 7.x-1.0 and 7.x-1.x-dev. The quickfix proposed in #5 fixes the problem. Is it a correct solution though or should the caller function check the source exists before calling parseSnippetData?

lodey’s picture

Status: Active » Needs review
FileSize
688 bytes

I can confirm we were still getting the JS issue, causing CKeditor to not show. This was even with the latest or dev version.
The patch mentioned in #5 worked in fixing it.

Attached is a patch file, just implementing the basic change suggested in #5.

DamienMcKenna’s picture

FileSize
560 bytes

Tidied up the code a little bit, can you verify the change to the if() statement still works?

lodey’s picture

Unfortunately that doesn't work for me.

typeof document.getElementById(source) is returning 'object' in my case.
document.getElementById(source) is returning 'null'

This works:
if (document.getElementById(source) != null) {}

DamienMcKenna’s picture

FileSize
546 bytes

So more like this?

lodey’s picture

Yep that works fine for me :)

robertragas’s picture

Status: Needs review » Fixed

Looks good, committed. Thanks!

Status: Fixed » Closed (fixed)

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