Problem/Motivation
This is a follow-up to #3564229: Admin Toolbar Search: Refactor admin_toolbar_search.js, where an initial round of refactoring of module's JS code was carried, during which several features or pieces of logic were identified and reported:
See comment #3:
Features to be reviewed:
- Give the ability to hide certain menu items in the breadcrumbs, displayed in search suggestions, when they are assigned the CSS class
'.admin-toolbar-search-ignore', see:
https://git.drupalcode.org/project/admin_toolbar/-/blob/3.x/admin_toolba...
Is that something really useful or necessary?
Corresponding currently to the following piece of JS code:
https://git.drupalcode.org/project/admin_toolbar/-/blob/3.x/admin_toolba...
const link = parent.querySelector(
// For each parent menu item, find the first child link without
// the CSS class 'admin-toolbar-search-ignore', to give the
// ability to ignore certain menu items from the breadcrumb.
'a:first-child:not(.admin-toolbar-search-ignore)',
);
Currently, there is no way to know this feature or piece of logic exists in the module, without actually reading the source code.
Steps to reproduce
1 - Add the class 'admin-toolbar-search-ignore' to a menu link in the admin toolbar, with JS, or in a twig/theme file, or through the interface with a contrib module (such as Menu Link Attributes).
2 - Check the menu link does not show in the breadcrumbs of the displayed menu items in Admin Toolbar Search resulting suggestions.
Proposed resolution
Determine whether this feature should be kept or removed: Is it really useful?
Could there be other ways the same type of requirements or results could be implemented with custom code?
(For example, some JS overriding some variable in a JS file in a custom module for a project)
Or could there be anything we could do to expose certain functions or variables allowing the logic to be implemented with some kind of override?
If the feature should be removed:
Could there be sites or projects using this feature?
For example: the class could be added to menu links defined by a custom module in a project/site.
Could there be a way we could deprecate or get rid properly of this feature in a clean/organized manner?
(To prevent certain sites from having an issue after an upgrade)
How critical could this change really be? (I would suppose, rather minor...)
Otherwise, if it needs to be kept:
1 - Write a small FunctionalJavascript test case with the steps described above.
2 - Document the feature so it is made clear to site builders, themers and front-end developers.
Future possible improvements:
- Provide different ways to load the Search field on the page (not only in the toolbar) ==> Support also Navigation, Gin, etc...
See: #3557278: Gin theme: Improve compatibility support. - Allow the menu links selector to be configurable to pick up links from any menu or markup on the page, for example to support core Navigation and pick up its links instead.
See: #3556898: Admin toolbar tools: Improve support for core Navigation.
Comments
Comment #2
dydave commentedNote: I personally don't use this feature, have never used it and had no idea it actually existed before looking in depth at module's JS file.
Comment #3
dydave commentedAdded possible future improvements, aiming at the very least, at providing Admin Toolbar Search support for the Gin Theme and Core Navigation module.
To be tested more carefully and probably detailed/described in a specific issue.