Skip to main content
added 374 characters in body
Source Link
Mazzy
  • 140
  • 4

I would recommend a 2 step approach to this.

  1. Add a link at the bottom of your block that links to the node like so:
<a class="my-block-link" href="node/1" title="My helpful title for screen readers">Full node</a>
  1. Use a jQuery snippet to link the whole block
$(document).on('click', '.contextual-region', function(e) {
  console.log('block clicked');
  window.location = $(this).find('.my-block-link').attr('href');
});
  1. UX Bonus points - Add this css for your linked block:
.contextual-region { cursor: pointer; }

EDIT:

I'll add a non JS way to make everyone happy:

{% block paragraph %}
  <div{{ attributes.addClass(classes) }}>
    {% block content %}
        <a href="{{ content.field_link.0['#url'] }}">
          <div class="content-container-needed">
          {{ content }}
          </div>
        </a>
    {% endblock %}
  </div>
{% endblock paragraph %}

I would recommend a 2 step approach to this.

  1. Add a link at the bottom of your block that links to the node like so:
<a class="my-block-link" href="node/1" title="My helpful title for screen readers">Full node</a>
  1. Use a jQuery snippet to link the whole block
$(document).on('click', '.contextual-region', function(e) {
  console.log('block clicked');
  window.location = $(this).find('.my-block-link').attr('href');
});
  1. UX Bonus points - Add this css for your linked block:
.contextual-region { cursor: pointer; }

I would recommend a 2 step approach to this.

  1. Add a link at the bottom of your block that links to the node like so:
<a class="my-block-link" href="node/1" title="My helpful title for screen readers">Full node</a>
  1. Use a jQuery snippet to link the whole block
$(document).on('click', '.contextual-region', function(e) {
  console.log('block clicked');
  window.location = $(this).find('.my-block-link').attr('href');
});
  1. UX Bonus points - Add this css for your linked block:
.contextual-region { cursor: pointer; }

EDIT:

I'll add a non JS way to make everyone happy:

{% block paragraph %}
  <div{{ attributes.addClass(classes) }}>
    {% block content %}
        <a href="{{ content.field_link.0['#url'] }}">
          <div class="content-container-needed">
          {{ content }}
          </div>
        </a>
    {% endblock %}
  </div>
{% endblock paragraph %}
Source Link
Mazzy
  • 140
  • 4

I would recommend a 2 step approach to this.

  1. Add a link at the bottom of your block that links to the node like so:
<a class="my-block-link" href="node/1" title="My helpful title for screen readers">Full node</a>
  1. Use a jQuery snippet to link the whole block
$(document).on('click', '.contextual-region', function(e) {
  console.log('block clicked');
  window.location = $(this).find('.my-block-link').attr('href');
});
  1. UX Bonus points - Add this css for your linked block:
.contextual-region { cursor: pointer; }