Closed (fixed)
Project:
Special menu items
Version:
7.x-2.x-dev
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
9 Jan 2019 at 01:56 UTC
Updated:
3 Apr 2023 at 11:44 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
jmcerdaComment #3
jmcerdaComment #4
damienmckennaI suspect this might be caused by another module or even the theme. It's common for people to make $variables['options']['attributes']['class'] a string when it really needs to be an array.
Please try this.
Comment #5
mark_fullmerAs described in the comment, the patch in #4 attempts to fix the problem of a site which is adding a class attribute as a string rather than an array.
However, the problem remains for PHP 7.1 and above for this line:
$variables['options']['attributes']['tabindex'][] = '0';This line is still applying an empty index operator to a string, which is disallowed per https://www.php.net/manual/en/migration71.incompatible.php
An additional problem with this line is that it will override any
tabindexvalues sent to it by thel()function. There are valid scenarios where the<nolink>render should not be focusable.The design of adding a tabindex to a
spantag is understandable, so that it behaves similar to a link. However, this behavior should be the fallback, not the the only possibility.We have a use case, for example, where we have adjacent links that point to the same destination, so for accessibility reasons, we want to set the
tabindexto-1, as shown below:In short, this module should respect the tabindex value, if it is already provided, and if not, it can fallback to a
0value that is not cast to array.The attached patch includes the fix in #4 (see interdiff) and additionally fixes the
tabindexfallback, while wrapping it in a conditional that will respect an existing value.Comment #6
poker10 commentedThanks for reporting this.
Regarding the
classattribute: This is not a bug of this module. Class must be an array as specified in the core documentation oftheme_linkfunction: https://api.drupal.org/api/drupal/includes%21theme.inc/function/theme_link/7.xI prefer not to "babysit" other modules/themes which does not follow documentation.
However I will take a look at the second problem (
tabindex), which seems valid.Comment #8
poker10 commentedCommitted and fixed the problem with
tabindex. Thanks all!I plan to roll-out a new release with few fixes from today soon.