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

Should code that targets CSS-safe contextual link names be clarified?

$
0
0

Problem/Motivation

  • outside_in_contextual_links_view_alter() has this code:
    if (isset($element['#links']['outside-inblock-configure'])) {
      $element['#links']['outside-inblock-configure']['attributes'] = [
  • 'outside-inblock-configure' seems like a strange name, especially without a hyphen between 'in' and 'block'. Searching the codebase for that string doesn't uncover where it comes from. Where it comes from is that outside_in.links.contextual.yml defines outside_in.block_configure, the keys of $element['#links'] in the above function are generated via Html::getClass() of the YML-defined link identifiers, and Html::getClass() converts '.' to empty string rather than hyphen.

Proposed resolution

Option 1:

Change the outside_in_contextual_links_view_alter() code to something like:

$link_class = Html::getClass('outside_in.block_configure');
if (isset($element['#links'][$link_class])) {
  $element['#links'][$link_class]['attributes'] = [

That's fine for the PHP side. However, what about JS code such as $(e.target).find('li.outside-inblock-configure a')?

Option 2:

Is there an option 2?

Remaining tasks

User interface changes

API changes

Data model changes


Viewing all articles
Browse latest Browse all 295019

Trending Articles



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