0

I'm building a Drupal 8 template/theme from scratch, and it is not showing the contextual editing options for my blocks when I view a site page. I.E., the little circles that are clicked to see options like "edit view," "configure block," etc.

I cloned the block.html.twig from the Bartik theme, so it has the attributes token that I thought was enough, like this:

<div{{ attributes.addClass(classes) }}>
 {{ title_prefix }}
 {% if label %}
   <h2{{ title_attributes }}>{{ label }}</h2>
 {% endif %}
 {{ title_suffix }}
 {% block content %}
   <div{{ content_attributes.addClass('content') }}>
     {{ content }}
   </div>
 {% endblock %}
 </div>

I can confirm the Contextual links module is active.

I have global access, so it shouldn't be a permissions issue.

Is there something more I need to do for this feature to be added in?

  • When you switch to the core default Bartik theme, do you see them? Also, there is a pencil icon ✏️ Edit at the top right of the admin toolbar that you can click, which reveals all the contextual links. Although, just hovering over an item should also reveal the contextual link. – No Sssweat May 22 at 9:51
  • When I switch to the default Bartik theme, yes, I see everything. The pencil icon and the contextual links on hovering over an item. All of this disappears in my custom theme. I'm sure there's something I just need to add in, but no clue what. I've just now removed my CSS file to see if it was causing the problem, but the contextual links are still missing. I can paste the page.html.twig or node twig - whatever's needed. I'm just not sure which is the most useful to post above – turpentyne May 22 at 18:48
  • 1
    When you inspect element with your browser, do see stuff like <ul class="contextual-links" hidden=""> and other stuff like class="contextual-region" and class="contextual ??? Also, check your browser's console for any JS errors. There could be some JS error blocking the contextual links reveal functionality. – No Sssweat May 22 at 21:03
  • oh! dang it! That was it. Viewing the console, I saw an error - There was a small syntax error: a / on a line by itself. The .js file is a small, completely unrelated file. Never occurred to me I should check that. Thank you! When I fixed that, everything appeared as intended. – turpentyne May 22 at 21:23
0

Per 'No Sssweat's comment above, this was due to a small syntax error in a custom javascript file, viewable in console. Once corrected, the contextual links worked as intended.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.