I am using Better expose filter auto-submit feature in one of my views filters.When I type something in search field,with the very first letter it starts searching while the user is still typing and throws the result without collecting all keywords.For example If I am searching for India,it will start searching as soon as it receives the First letter of the word 'I' and again on 'N' keyword entry.There needs to be some sort of delay so that user can enter the string which needs to be searched properly.
There is an auto_submit library attached to this module containing the auto_submit.js file in js directory.
Comment | File | Size | Author |
---|---|---|---|
#35 | better_exposed_filters-2921744-35.patch | 4.11 KB | StijnStroobants |
#24 | interdiff.txt | 620 bytes | rlhawk |
#24 | 2921744-24.patch | 4.29 KB | rlhawk |
#18 | better_exposed_filters-autosubmit_delay-2921744-18.patch | 3.68 KB | tostinni |
#17 | better_exposed_filters-autosubmit-2921744-17.patch | 1.1 KB | oxyc |
Comments
Comment #2
sagesolutions CreditAttribution: sagesolutions commentedAlso related to this issue, when typing in the search box and make a typo, hitting backspace doesn't remove a character. Instead it triggers the browser's back button.
This happens because the search results are returned, and you are no longer inside the search box.
Comment #3
C13L0 CreditAttribution: C13L0 as a volunteer commentedAgreed! This needs some sort of a delay. It's nearly impossible to use autosubmit on an exposed combined field.
Comment #4
Kushal Bansal CreditAttribution: Kushal Bansal commentedHi @C13L0
The solution for an delay can be submitting a patch for it for the file auto_submit.js in js folder at line no 84
Drupal.debounce(triggerSubmit, 500)($target);
if we can change the Delay to 1500 ,it will improve the way it works.
Will submit a patch for this file.
Comment #5
sagesolutions CreditAttribution: sagesolutions commentedThat will work pretty well I think.
I was wondering, should it auto-submit at all when the user is typing in the textfield? I think changing select options or checking checkboxes should auto-submit the form, but maybe not auto-submit while the user is typing. Thoughts?
Comment #6
Kushal Bansal CreditAttribution: Kushal Bansal commentedThe code for this is written on behalf of on keyup events.So it is working like that!
Comment #7
Kushal Bansal CreditAttribution: Kushal Bansal commentedI am submitting this file which contains the updated auto_submit.js file to fix the time delay issue .
Comment #8
Kushal Bansal CreditAttribution: Kushal Bansal commentedHere The delay has been increased from 500 to 1500
Comment #9
joake CreditAttribution: joake commentedAnother option is to set the data-bef-auto-submit-exclude="1" on the input field in question. This can be done in hook_form_alter, this will prevent said field from triggering auto update entirely.
Comment #10
Coufu CreditAttribution: Coufu at iFactory commented#9 worked for me. Thanks joake.
Comment #11
luzitano CreditAttribution: luzitano at iFactory commented#9 also worked for me. In fact, I just went ahead and made all text inputs in exposed filters across all views have this attribute set.
Comment #12
Alireza.Tabatabaeian CreditAttribution: Alireza.Tabatabaeian commentedTried to test #9 so I implemented the below code:
well, I know I might be implementing it wrong so I wanted to ask how can I set this option on my form element?
@luzitano can you share your code if you don't mind?
Comment #13
Kleve CreditAttribution: Kleve at Happiness commentedThis is how I implemented it.
Comment #14
interdruper CreditAttribution: interdruper at Interdruper commentedYep, #9 approach works. Note that this is also required for autocomplete filters, like i.e. $form['uid'].
Comment #15
matsbla CreditAttribution: matsbla at Globalbility commentedI don't think #9 is a good solution, it simply turns off the autosubmit for text fields, but what if you need autosubmit when the user have finished typing?
#8 gave a slight improvement, but doesn't makes it possible to write longer words. I think we need a debounce that check if user where still typing e.g. the last second, and continue to wait autosubmit until user have not typed anything for the last second.
Comment #16
trebormcI created a patch to detect when you stop typing. There is a wait of 1s to make sure that it is not because the user types slow.
Comment #17
oxyc CreditAttribution: oxyc as a volunteer commentedThe issue is that debounce is used incorrectly. This is not pretty but it fixes it.
Comment #18
tostinni CreditAttribution: tostinni at Agence Propal commentedSince #2880307: Allow Textfields to be excluded from AutoSubmit, there's the option in the UI to disable ajax on textfields.
Regarding the patch, I think adding a delay is a good idea but it should be configurable, so here is a patch that adds a setting for this.
It's only visible if "Autosubmit" is checked and "Exclude Textfield" isn't.
Comment #19
fotidim CreditAttribution: fotidim commentedIt would also make sense to search when there are at least 3 characters in the field. This can also be configurable.
Comment #20
BrightBold@tostinni (and previous patch contributors) You are lifesavers! The patch in #18 fixed my problem. We are using an autocomplete field so needed a 1500ms delay, so I really appreciated the configurable setting.
From my perspective this is RTBC but I've put it to Needs review so that someone else can confirm.
Comment #21
sonvir249 CreditAttribution: sonvir249 as a volunteer and at QED42 commentedThe patch in #18 fixed my problem. Thank you @tostinni, for the patch
Comment #22
matsbla CreditAttribution: matsbla at Globalbility commentedA similar solution is being worked on for ctools
Comment #23
Sharique CreditAttribution: Sharique at Acquia commented+1 for RTBC, It fixed the issue for me also.
Comment #24
rlhawkWhenever a new setting is added, the configuration schema needs to be updated to include it. Here a new patch (and interdiff) that updates the schema.
Comment #25
jeremyr CreditAttribution: jeremyr as a volunteer commentedConfirming that #24 works.
Comment #26
brayfe CreditAttribution: brayfe as a volunteer commentedHave also confirmed that the patch #24 works with BEF 8.x-3.x-dev on Drupal 8.6.14.
I'd be interested to hear the use case for having auto_submit on an exposed Textfield in the first place. It seems strange, especially if there is already a "Submit/Apply" button. It also negates the natural behavior to push the "enter" key to submit. Seems like what people want is an ajax form for this textfield vs auto_submit.
Comment #27
brayfe CreditAttribution: brayfe as a volunteer commentedChanging this to RTBC as it allows the configuration of the autosubmit delay. Up for consideration, for anyone who comes across this post in the future, is the suggestion in #9 (don't autosubmit text fields).
Comment #29
rlhawkThanks, all.
Comment #31
turpentyne CreditAttribution: turpentyne commentedForgive a beginner question on a closed item, but...
Would the patch in #24 above, work on 8.x-3.0-alpha6 ?
I don't see BEF 8.x-3.x-dev available for install. I tried installing better_exposed_filters 8.x-4.x-dev, but it broke the site, so I reverted to alpha6, since it seemed more stable on my site, for the moment.
Comment #32
alberto56 CreditAttribution: alberto56 at Dcycle commented@turpentyne yes it will. You will notice that the patch was committed on April 12, and the alpha6 version dates from before that. So, yes, it will apply.
Comment #33
StijnStroobantsRe-rolled the patch against the 8.x-4.x- branch.
Comment #34
StijnStroobantsForgot to attach the drupalSettings. New patch uploaded.
Comment #35
StijnStroobantsComment #36
StijnStroobantsI would like to re-open this issue for review as this functionality was not implemented in 8.x-4.x
Comment #37
StijnStroobantsComment #38
StijnStroobantsOpened a new issue for the missing functionality of in the 8.x-4.x branch: https://www.drupal.org/project/better_exposed_filters/issues/3098809