Preserve Input Search Value

Created on 10 November 2022, about 2 years ago
Updated 3 February 2023, almost 2 years ago

Problem/Motivation

We have a use case to preserve the search input that was used, which provides a better UX for the user in the long run.

Feature request
Status

Needs review

Version

1.0

Component

Code

Created by

🇺🇸United States droath

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.

  • 🇨🇦Canada phjou Vancouver 🇨🇦 🇪🇺

    Nice feature.
    Should we make this a checkbox in the block configuration to enable or disable this feature? And we would enable this by default.

    - If people want to customize in their theme, it might be best to have an option to not add any javascript.
    - It might be best if the javascript was based on a class that we add ourselves because in a theme the class "form-search" could be missing or used in other spots.

  • Status changed to Needs work almost 2 years ago
  • 🇨🇦Canada phjou Vancouver 🇨🇦 🇪🇺
  • I thought about something like this:

  • Status changed to Needs review 6 months ago
  • 🇮🇳India Vivek Panicker Kolkata

    This patch worked for me!

  • 🇮🇳India Vivek Panicker Kolkata

    Converted patch#7 to MR.

  • Status changed to RTBC 4 months ago
  • 🇮🇳India atul_ghate

    I have reproduced the issue successfully.
    The MR8 is applied cleanly.

    I followed the steps below to reproduce the issue:

    1.Cloned the 1.0.x version of the module.
    2.Installed its dependencies and enabled both modules.
    3.Create a view for content and add exposed filter and configure
    4.add serach api form by configuring it with key and action view url
    5.Reproduced the issue both without MR8 changes and with MR8 applied.
    Changing its status to RTBC.

  • Status changed to Needs work 7 days ago
  • 🇨🇦Canada phjou Vancouver 🇨🇦 🇪🇺

    I would probably set the cache to only be set on the query parameter and not the whole URL. That way we have a unique cache when the parameter is not there.

    $form['#cache']['contexts'][] = 'url.query_args:' . $input_name;
    

    PS: I didn't test this code, just followed the documentation:
    https://www.drupal.org/docs/drupal-apis/cache-api/cache-contexts

Production build 0.71.5 2024