Quantcast
Channel: Issues for Drupal core
Viewing all articles
Browse latest Browse all 293831

contextual.js and quickedit.js should fail gracefully, with useful error messages, when Twig templates forget to print attributes

$
0
0

Problem/Motivation

We have issues with JS errors caused by contextual module and quickedit module.

We seem to have some non-standard markup, missing wrappers/data attributes/classes and then the JS in those modules fails hard.

To reproduce, remove all attributes from nodes in bartik's node.html.twig:

diff --git a/core/themes/bartik/templates/node.html.twig b/core/themes/bartik/templates/node.html.twig
index 25144bf..5089563 100644
--- a/core/themes/bartik/templates/node.html.twig
+++ b/core/themes/bartik/templates/node.html.twig
@@ -72,7 +72,7 @@'clearfix',
   ]
 %}
-<article{{ attributes.addClass(classes) }}>
+<article><header>
     {{ title_prefix }}
     {% if not page %}

Then clear caches and look at a node with quickedit/contextual links enabled.

As discussed on IRC, it is expected that it can't work properly.. but it should give me a helpful error in the console or ignore it.. but not break completely.

Proposed resolution

Fixing it seem to be relatively easy but I'm can't fully explain what markup exactly is causing it, at least not the contextual.js part. For quickedit, it seems to be a field that is not wrapped in an entity wrapper, which is the case for at least some block_content entities on my site, apparently.

Remaining tasks

User interface changes

API changes

Data model changes

Only local images are allowed.


Viewing all articles
Browse latest Browse all 293831

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>