Issue #1877482 by bertramakers | benjifisher: Fixed Toolbar tabs should have ID attributes based on hook_toolbar() array keys rather than sequentially numbering.
parent
1397bd65bc
commit
b733559eb7
|
@ -7,7 +7,9 @@
|
||||||
|
|
||||||
namespace Drupal\toolbar\Element;
|
namespace Drupal\toolbar\Element;
|
||||||
|
|
||||||
|
use Drupal\Component\Utility\Html;
|
||||||
use Drupal\Core\Render\Element\RenderElement;
|
use Drupal\Core\Render\Element\RenderElement;
|
||||||
|
use Drupal\Core\Render\Element;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides a render element for the default Drupal toolbar.
|
* Provides a render element for the default Drupal toolbar.
|
||||||
|
@ -97,6 +99,11 @@ class Toolbar extends RenderElement {
|
||||||
// Merge in the original toolbar values.
|
// Merge in the original toolbar values.
|
||||||
$element = array_merge($element, $items);
|
$element = array_merge($element, $items);
|
||||||
|
|
||||||
|
// Assign each item a unique ID, based on its key.
|
||||||
|
foreach (Element::children($element) as $key) {
|
||||||
|
$element[$key]['#id'] = Html::getId('toolbar-item-' . $key);
|
||||||
|
}
|
||||||
|
|
||||||
// Render the children.
|
// Render the children.
|
||||||
$element['#children'] = drupal_render_children($element);
|
$element['#children'] = drupal_render_children($element);
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,6 @@
|
||||||
|
|
||||||
namespace Drupal\toolbar\Element;
|
namespace Drupal\toolbar\Element;
|
||||||
|
|
||||||
use Drupal\Component\Utility\Html;
|
|
||||||
use Drupal\Core\Render\Element\RenderElement;
|
use Drupal\Core\Render\Element\RenderElement;
|
||||||
use Drupal\Core\Url;
|
use Drupal\Core\Url;
|
||||||
|
|
||||||
|
@ -50,8 +49,7 @@ class ToolbarItem extends RenderElement {
|
||||||
* A renderable array.
|
* A renderable array.
|
||||||
*/
|
*/
|
||||||
public static function preRenderToolbarItem($element) {
|
public static function preRenderToolbarItem($element) {
|
||||||
// Assign each item a unique ID.
|
$id = $element['#id'];
|
||||||
$id = Html::getUniqueId('toolbar-item');
|
|
||||||
|
|
||||||
// Provide attributes for a toolbar item.
|
// Provide attributes for a toolbar item.
|
||||||
$attributes = array(
|
$attributes = array(
|
||||||
|
|
Loading…
Reference in New Issue