Problem/Motivation

Sometimes I do not know where exactly the menu item is or it is in a deep hierarchy.

Proposed resolution

- Add additional toolbar for search
- Implement search field that administration links.

Remaining tasks

- Implement search field
- Write functional test
- Needs Review

User interface changes

Add search field in toolbar, like admin_menu had.

API changes

- None

Data model changes

- None

CommentFileSizeAuthor
#32 interdiff-30-32.txt1.49 KBoknate
#32 admin-toolbar-search-2986082-32.patch10.05 KBoknate
#31 no margin built into css screenshot 2.png20.94 KBoknate
#30 admin-toolbar-search-2986082-30.patch9.24 KBoknate
#30 interdiff-27-30.txt411 bytesoknate
#29 margin built in.png10.8 KBoknate
#28 no margin built into css.png2.86 KBoknate
#27 interdiff-26-27.txt1.09 KBoknate
#27 admin-toolbar-search-2986082-27.patch9.22 KBoknate
#26 interdiff-24-26.txt588 bytesoknate
#26 admin-toolbar-search-2986082-26.patch9.08 KBoknate
#24 interdiff-22-24.txt515 bytesoknate
#24 admin-toolbar-search-2986082-24.patch9.19 KBoknate
#22 interdiff-17-22.txt502 bytesoknate
#22 admin-toolbar-search-2986082-22.patch9.23 KBoknate
#18 interdiff-16-17.txt699 bytesoknate
#18 admin-toolbar-search-2986082-17.patch9.2 KBoknate
#17 interdiff-15-16.txt2.26 KBoknate
#17 admin-toolbar-search-2986082-16.patch9.23 KBoknate
#16 add article.png27.23 KBoknate
#15 admin-toolbar-search-2986082-15.patch6.98 KBoknate
#15 interdiff-12-15.txt1.53 KBoknate
#12 interdiff-8-12.txt2.49 KBoknate
#12 admin-toolbar-search-2986082-12.patch6.04 KBoknate
#12 active.png8.63 KBoknate
#12 inactive.png8.34 KBoknate
#8 interdiff-7-8.patch1.49 KBoknate
#8 admin-toolbar-search-2986082-8.patch4.8 KBoknate
#8 greyed out url.png52.28 KBoknate
#7 admin-toolbar-search.png53.02 KBoknate
#7 admin-toolbar-search-2986082-7.patch4.41 KBoknate
#7 interdiff-5-7.txt1.19 KBoknate
#5 example-admin-toolbar-search.png77.4 KBoknate
#5 admin-toolbar-search-2986082-5.patch3.97 KBoknate

Comments

Bobík created an issue. See original summary.

eme’s picture

Hello. I advise you to install the Coffee module (https://www.drupal.org/project/coffee).

romainj’s picture

You can try the Navbar Filter module too.

teknorah’s picture

Unfortunately, I have run into issues using coffee because it builds it's search index based on available routes, of which, many require parameters.

I have submitted an issue regarding this and the suggestion to build the search index similar to how this module does.

oknate’s picture

Here's a patch that adds a search toolbar with redirect on autocomplete selection.
admin toolbar search

Since it can often take a long time for a new feature to get added to a module, I've added this as a separate module for now:
https://www.drupal.org/project/admin_toolbar_search

oknate’s picture

Status: Active » Needs review
oknate’s picture

StatusFileSize
new1.19 KB
new4.41 KB
new53.02 KB

Here's an updated patch that adds breadcrumbs, to add a little context.
added breadcrumbs
I also updated the module based off this patch.

oknate’s picture

StatusFileSize
new52.28 KB
new4.8 KB
new1.49 KB

Adding some visual separation between the label and the url in the suggestions

greyed out url

Status: Needs review » Needs work

The last submitted patch, 8: interdiff-7-8.patch, failed testing. View results

oknate’s picture

Status: Needs work » Needs review

Oops, should have used .txt for the interdiff.

adriancid’s picture

Status: Needs review » Needs work

Thanks for the patch, is great!

I just have this comments:

+++ b/js/admin_toolbar_search.js
@@ -0,0 +1,58 @@
+      var baseUrl = getUrl .protocol + "//" + getUrl.host + "/";

Here should be getUrl.protocol

And I think we should use the loupe icon as this is a search:

core/themes/stable/images/core/icons/424242/loupe.svg

oknate’s picture

Status: Needs work » Needs review
StatusFileSize
new8.34 KB
new8.63 KB
new6.04 KB
new2.49 KB

active
inactive

Since they didn't have svgs in core for the loupe in the colors I wanted, I added them in the patch. I'm using the same colors as the devel toolbar icon.

adriancid’s picture

Status: Needs review » Reviewed & tested by the community

Thanks, its fine for me, let's see the other maintainers opinions.

oknate’s picture

Thanks, @adriancid!

oknate’s picture

Status: Reviewed & tested by the community » Needs review
StatusFileSize
new1.53 KB
new6.98 KB

I have been using this, and I noticed an improvement that could be added.

Currently, searches such as "add article" don't work because the label for add article contains "Content > Add Content > Article" and the url, but not the exact string "add article". I thought it would be nice to allow keyword based search, so that a search for "add article" would return the add article link.

oknate’s picture

StatusFileSize
new27.23 KB

Example of keyword-based search:
keyword-based search

I've marked this issue back as "Needs Review" as I made changes. So if the changes in #15 could be reviewed, I would appreciate it.

oknate’s picture

StatusFileSize
new9.23 KB
new2.26 KB

Adding functional test for search functionality.

oknate’s picture

StatusFileSize
new9.2 KB
new699 bytes

fixing namespace, and removing admin_toolbar_tools dependency.

oknate’s picture

Status: Needs review » Reviewed & tested by the community

I'm going to mark this back to RTBC, in the hopes that the other maintainers (other than Adrian Cid) will give this a look (see #13). Keep in mind the updates after #13 are not RTBC.

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 18: admin-toolbar-search-2986082-17.patch, failed testing. View results

oknate’s picture

Issue summary: View changes
oknate’s picture

Status: Needs work » Reviewed & tested by the community
StatusFileSize
new9.23 KB
new502 bytes

Oops, adding back admin_toolbar_tools dependency in test.

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 22: admin-toolbar-search-2986082-22.patch, failed testing. View results

oknate’s picture

StatusFileSize
new9.19 KB
new515 bytes

I realized I had a dependency on the module version of this, "admin_toolbar_search", removing.

oknate’s picture

Status: Needs work » Reviewed & tested by the community

Marking this back to RTBC, (based on #13) in the hopes that the other maintainers (other than Adrian Cid) will give this a look. Keep in mind the updates after #13 are not RTBC.

Updates since #13:
- Added keyword based search.
- Added functional test.

oknate’s picture

StatusFileSize
new9.08 KB
new588 bytes

Minor update to test, removing unused variable.

oknate’s picture

StatusFileSize
new9.22 KB
new1.09 KB

Minor update to add some basic styles to the input and to make the label bold.

I found that when using my admin theme, it was inheriting nice styles, but on my main theme, the tray was getting squashed because there wasn't any default margin or padding added in admin.toolbar_search.css.

This updated patch adds some default styles, so that if a theme doesn't have styles in place, the margins should be OK as a baseline.

It also removes a whitespace error.

oknate’s picture

StatusFileSize
new2.86 KB

Here's a screenshot of the issue patch #27 is addressing. Out of the box, no margin is added around the input.
css lack of basic margin

oknate’s picture

StatusFileSize
new10.8 KB

test

oknate’s picture

StatusFileSize
new411 bytes
new9.24 KB

Autocomplete should wait until two characters have been entered.

Currently, it will trigger autocomplete if only one character has been typed. Since we're not limiting the number of items returned, this leads to a very long ugly list of items related to the one letter typed. The minimum should be set to two characters.

oknate’s picture

StatusFileSize
new20.94 KB

Updates since #13:
- Added keyword based search.
- Added functional test.
- Added some basic css styles
- Wait for second character typed to trigger autocomplete

oknate’s picture

StatusFileSize
new10.05 KB
new1.49 KB

Here's an update that adds "auto focus", that is, when you click on the tab, it will focus into the search field.

  • adriancid committed 2cfb1d8 on 8.x-1.x authored by oknate
    Issue #2986082 by oknate, Bobík, adriancid: Add search for menu items
    
  • adriancid committed c0e8a41 on 8.x-1.x authored by oknate
    Issue #2986082 by oknate, Bobík, adriancid: Add search for menu items
    
adriancid’s picture

Status: Reviewed & tested by the community » Fixed

@oknate thanks for this feature.

oknate’s picture

Fantastic. Thanks for merging it in.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

denisev’s picture

What is the recommended way to disable this feature?

oknate’s picture

The same way it's added, using hook_toolbar_alter().

function mymodule_toolbar_alter(&$items) {
  if (!empty($items['administration_search']) {
    unset($items['administration_search']);
  }
}