Place the autocomplete next to the filter

Created on 3 December 2021, almost 3 years ago
Updated 10 September 2024, 2 months ago

For better theming and usability it would be better if the autocomplete results are placed next to the filter that triggers the autocomplete.

✨ Feature request
Status

Needs review

Version

1.0

Component

User interface

Created by

πŸ‡§πŸ‡ͺBelgium cgoffin

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

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡¦πŸ‡ΉAustria drunken monkey Vienna, Austria

    Could you please review so I can merge your MR?

  • πŸ‡ΊπŸ‡ΈUnited States kyleleber

    @drunken monkey,

    I am running into a similar need as the original poster, so glad to help out with this one. I've applied the patch from your commit (https://git.drupalcode.org/project/search_api_autocomplete/-/merge_reque...), and there seems to be an issue with the data-autocomplete-appendTo attribute that is being added if i'm understanding things correctly. In core's form-element.html.twig (https://api.drupal.org/api/drupal/core%21modules%21system%21templates%21...), the "form-type-{X}" class isn't being added, but js-form-type-{X} is. Presumably, the form-type-{X} class is being added via a base theme such as classy, which not every theme would declare as a base theme. I was able to at least test things and confirm things looked good on my end by changing

    $element['#attributes']['data-autocomplete-appendTo'] = ".form-type-search-api-autocomplete:has(.{$class})";

    to

    $element['#attributes']['data-autocomplete-appendTo'] = ".js-form-type-search-api-autocomplete:has(.{$class})";

    Again, I am not entirely sure if we could rely on the ".js-form-type-{X}" selector depending if folks would have overridden that template. However, I think if we could change the class to something at the core template level, rather than as a core theme level, it could help generalize things.

    Let me know what you think or if you see any issues with that approach!

  • πŸ‡¦πŸ‡ΉAustria drunken monkey Vienna, Austria

    @kjl16: Not really sure what you mean, I don’t see any data-autocomplete-appendTo attribute, for example.
    I’ll just let you themers figure out the best way forward amongst you and will then probably just commit the result.

  • πŸ‡§πŸ‡ͺBelgium cgoffin

    @kjl16 @drunken monkey we can also remove the data-autocomplete-appendTo attribute and append it to the parent with the jQuery .parent() selector. Does that sound like a good solution?

    uiAutocomplete.element.autocomplete( "option", "appendTo", uiAutocomplete.element.parent());

    instead of

    uiAutocomplete.element.autocomplete( "option", "appendTo", uiAutocomplete.element.attr('data-autocomplete-appendTo'));

    in search_api_autocomplete.js

  • Open on Drupal.org β†’
    Core: 9.5.x + Environment: PHP 8.1 & sqlite-3.27
    last update about 1 year ago
    Not currently mergeable.
  • Open in Jenkins β†’ Open on Drupal.org β†’
    Core: 9.5.x + Environment: PHP 8.1 & sqlite-3.27
    last update about 1 year ago
    34 pass
  • πŸ‡§πŸ‡ͺBelgium cgoffin

    Here a new patch against v1.8.0.

  • πŸ‡³πŸ‡±Netherlands Tom Grootjans Hoofddorp, The Netherlands

    tom grootjans β†’ made their first commit to this issue’s fork.

  • Pipeline finished with Success
    2 months ago
    Total: 353s
    #279191
  • πŸ‡³πŸ‡±Netherlands Tom Grootjans Hoofddorp, The Netherlands

    Here is a new patch against v1.9.0

Production build 0.71.5 2024