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.
| Comment | File | Size | Author |
|---|---|---|---|
| #12 | search_api_block_preserve_input_value-3320560-12.patch | 1.09 KB | kir lazur |
| #10 | after_patch1.mp4 | 1.81 MB | atul_ghate |
| #10 | before_patch1.mp4 | 903.61 KB | atul_ghate |
| #3 | search_api_block_perserve_input_value-3320560-3.patch | 1.87 KB | droath |
| #2 | search_api_block_perserve_input_value-3320560-2.patch | 1.95 KB | droath |
Issue fork search_api_block-3320560
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
Comment #2
droath commentedComment #3
droath commentedComment #4
phjouNice 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 (potential js conflict). (disable that feature)
- 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.
Comment #5
phjouComment #6
lus commentedI thought about something like this:
Comment #7
vivek panicker commentedThis patch worked for me!
Comment #9
vivek panicker commentedConverted patch#7 to MR.
Comment #10
atul_ghate commentedI 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.
Comment #11
phjouI 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.
PS: I didn't test this code, just followed the documentation:
https://www.drupal.org/docs/drupal-apis/cache-api/cache-contexts
Comment #12
kir lazur commentedhere's updated version of patch
Comment #13
vivek panicker commented@phjou I agree your solution is better. The cache variation then would only depend on the specific query argument based on the input field name and not on the entire URL. So even if other query args are present, the cached data would ignore those.
Comment #14
sachbearbeiter commentedBtw. cool feature : )
Comment #15
phjouI guess we want to set the context only if the input name is not empty. Otherwise it looks good
Comment #17
phjouComment #18
vivek panicker commentedHey @phjou! Thank you for merging the fix!
I would just like to inform you that according to the latest update, the maintainer has to manually provide credits to the involved participants in the Credit and Committing section in the issue.
So if anyone deserves credit here, kindly do give them! :)
Comment #19
phjouComment #20
phjou@vivek Thanks for the reminder, I added the credits. I was too used to the time where the checkboxes were checked by default when somebody was uploading a file.