Problem/Motivation

When searching via the admin toolbar search field, if there are no results, nothing happens and there is no evidence that a search was performed. Without doing another search, it's not possible to tell whether there are no results or if something is not working. It may be nice to have a simple "No results found" message appear for cases where there are no matches.

Steps to reproduce

Do a search for something with no results and see that nothing happens.

Proposed resolution

Include a "No results found" message when no results are found to let the user know that a search was actually performed.

  • The message is displayed as a suggestion that is not a link and cannot be selected.
  • Screen readers are told there are no results, not one result.

Remaining tasks

  • Review and test the merge request.

User interface changes

A "No results found" item is displayed in the search suggestions when no menu link matches.

API changes

None.

Data model changes

None.

CommentFileSizeAuthor
#4 Before MR.png97.13 KBkanchan bhogade
#4 After MR.png98.81 KBkanchan bhogade
Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

chrisla created an issue. See original summary.

chrisla’s picture

Status: Active » Needs review

I believe my submitted MR adds a usable "no results" option to the search tool that is also not clickable as a link. I am very happy to get feedback or updates to the code submitted.

kanchan bhogade’s picture

StatusFileSize
new98.81 KB
new97.13 KB

Hi
Tested MR 164 on Drupal 11.x
Applied MR successfully...

The "No results found" message when no results are found is displayed.

Attaching screenshot for reference

dydave made their first commit to this issue’s fork.

dydave’s picture

Version: 3.6.1 » 3.x-dev
Status: Needs review » Active

The merge request in this issue is now outdated.... given all the changes to the admin_toolbar_search.js in the last 3.6.3 release.

I've started working on the updated MR, but need a bit more time to refine user interactions in the JS....
I'm probably going to have to ask for a bit of help and review from my colleagues more specialized in JS and CSS (Front-end developers), so it's going to take a bit more time ...

Moving back to Active and for the dev branch.... coming back soon to this issue 👌

In any case, any feedback, suggestions, opinions or recommendations for this feature would be greatly appreciated.
Thanks in advance!

dydave changed the visibility of the branch 3532958-3532958-search-no-results-eslint to hidden.

dydave changed the visibility of the branch 3532958-search-no-results to hidden.

dydave’s picture

Issue summary: View changes
Status: Active » Needs review

Thanks a lot @chrisla for the report and the initial merge request, and @kanchan bhogade for testing it! 🙏

As mentioned at #6, MR !164 was outdated after the refactoring of admin_toolbar_search.js, so I created a new merge request MR !228, with the feature reimplemented on the current code. I'm moving the issue to Needs review: any review, testing and feedback would be greatly appreciated.

How it works

  • When no menu link matches the search, the suggestion list displays a single "No results found" item (translatable), instead of staying hidden.
  • It is plain text, not a link, and it cannot be selected: clicking it, or moving to it with the arrow keys and pressing Enter, does nothing and keeps the search query in the input field.
  • Accessibility: jQuery UI announces the number of results in a live region, which would have been "1 result is available" for the message. It now announces "No results found" in that case.
  • The item is not highlighted when hovered or focused and uses the default cursor, since it is not clickable.
  • A new JavaScript test, AdminToolbarSearchNoResultsTest, covers the message, the click and the keyboard interactions, and the links displaying again for a matching query. It fails without the change.

How to test

  1. Use Admin Toolbar 3.x-dev with the MR (with or without Admin Toolbar Tools).
  2. In the toolbar, type a search matching no link, for example nonexistent: "No results found" is displayed, not as a link.
  3. Click it, or move to it with the arrow keys and press Enter: nothing happens and the query is kept.
  4. Type a search matching links, for example basic: the links are displayed, without the message, and still work.

What we would like feedback on

  • The display of the message in the toolbar field and in the search tab tray (mobile and wide screens), and with other admin themes such as Gin.
  • The behavior with a screen reader, if possible.
  • The wording: "No results found". Would something else be clearer?

One known limitation: the extra links of Admin Toolbar Tools are loaded asynchronously the first time the field is focused, so a query typed before they arrive may show the message until the next keystroke. This is not changed in this MR.

Thanks in advance! 🙏

ressa’s picture

Status: Needs review » Reviewed & tested by the community

Thanks @chrisla and @dydave for creating this feature! It works well, and if I type in text in the search field for a page that does not exists (like "contentt") the text "No results found" is display, which is not clickable.

  • dydave committed 28235d9a on 3.x
    Issue #3532958 by chrisla, dydave, ressa: Display a 'No results found'...
dydave’s picture

Status: Reviewed & tested by the community » Fixed

Merged, thanks!

The Admin Toolbar Search now displays a No results found message when no menu link matches the search:

  • The message is displayed in the suggestions list as plain text, not as a link: it cannot be selected, keeps the search query in the input field and does not navigate when clicked or when pressing Enter.
  • The message is announced to screen readers instead of the default "1 result is available" message of jQuery UI Autocomplete.
  • It works with the search field displayed in the toolbar and with the search input displayed in the tray of the search tab.
  • The suggestion links are now rendered with DOM nodes and textContent instead of an HTML string, and the labels are stored as plain text.
  • Added the CSS variable --admin-toolbar-search-item-color for the color of the suggestions.
  • Added a FunctionalJavascript test (AdminToolbarSearchNoResultsTest) covering the message, the screen reader announcement, clicking, the keyboard and both search inputs.

Thanks to chrisla for the initial merge request and idea, and to kanchan bhogade for testing it!

Known limitation, which could be handled in a follow-up issue: if a search is typed before the extra links of Admin Toolbar Tools have finished loading, the message can be displayed until the next keystroke refreshes the suggestions.

We'll have to keep an eye on this one...

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

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