Suggestions as label

Created on 9 July 2023, over 1 year ago
Updated 7 October 2023, about 1 year ago

Problem/Motivation

I have added a first element to the suggestions like to be kind of the title. e.g `Suggested Results`

Steps to reproduce

- Add the following code

function hook_search_api_autocomplete_suggestions_alter(array &$suggestions, array $alter_params) {
  // Add text at the top of the list.
  $default_text = new Suggestion(NULL, Url::fromRoute('<nolink>'), NULL, 'Suggested results:');
  array_unshift($suggestions, $default_text);

- Start typing in the search text input
- Click on the first autocomplete results, `Suggested Results`

Proposed resolution

- Add a check to see if url is empty, do nothing

🐛 Bug report
Status

Closed: won't fix

Version

1.0

Component

General code

Created by

🇲🇺Mauritius whiz11

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @whiz11
  • 🇲🇺Mauritius whiz11

    Adding a patch to get around this

  • Status changed to Closed: won't fix about 1 year ago
  • 🇦🇹Austria drunken monkey Vienna, Austria

    You provide steps to reproduce and a suggested solution, but don’t mention what the actual problem is. In the future, please include a clear description of what you would say should happen, and what does happen.

    Anyways, it’s really by design that “suggestions” provide suggested actions and are not meant for merely decorative purposes. If you want to add a heading to the search results, I suggest finding a way to do that in a clean way via jQuery UI Autocomplete, not by trying to make it work by adding a “dummy” suggestion for it.

Production build 0.71.5 2024