Problem/Motivation
We have a custom admin toolbar item in Drupal 10.2.4, added via hook_toolbar, as per the instructions here https://drupal.stackexchange.com/a/215404.
Literally this:
function module_name_toolbar() {
$items = [];
$items['module_name'] = [
'#cache' => [
'contexts' => [
'user.permissions',
],
],
];
$items['module_name'] += array(
'#type' => 'toolbar_item',
'tab' => [
'#type' => 'html_tag',
'#tag' => 'button',
'#value' => t('Title'),
'#attributes' => array(
'class' => array('toolbar-icon', 'toolbar-icon-help', 'toolbar-item'),
'aria-pressed' => 'false',
'type' => 'button',
'title' => 'hover text',
),
],
'#wrapper_attributes' => [
'class' => [
'toolbar-tab'
],
'id' => 'toolbar-tab-docs',
],
'#attached' => array(
'library' => array(
'module_name/library_name
),
),
);
return $items;
}
.. and the JS code, which just performs a simple redirect:
(function ($) {
$( "#toolbar-tab-docs" ).click(function() {
console.log("the link was hit");
window.open("/some/redirect", "_blank");
});
})(jQuery);
it works fine until we enable Gin theme whereupon the link stops responding - it doesn't even fire the Javascript.
Steps to reproduce
- Install Drupal 10.2.4.
- Add the above code in a custom .module file, enable the module
- Test the link - it works
- Enable the latest Gin theme RC (9)
- Test the link - it doesn't even log to the console.
Proposed resolution
Remaining tasks
User interface changes
API changes
Data model changes