-
Notifications
You must be signed in to change notification settings - Fork 331
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Autoselect on blur #113
Comments
Hey @voidale, I would love to review such a PR, go ahead 👍 |
I set the autoselectOnBlur to true, and now it selects an input on (iOs safari) on touch, but one major problem is no matter what you click it always selects the first input? So if theres 3 suggestions and you click suggestion 2 it's still suggestions 1 thats selected. No i need more options for it to work properly or is it a general issue? |
Should not need anything else. I need to reproduce the bug locally, maybe it's an issue with Safari. |
try to visit https://iclaimer.com/iframe/claim-form/da/flyhjaelp-dk on "iphone" and try the first autoselect box out then you can see the issue. |
The code used is let client = algoliasearch("xxxx", 'xxxxx');
let index = client.initIndex(this.index);
let searchOptions = { hitsPerPage: 6, filters: 'company_id = '+this.companyId };
let iOS = /iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream;
if( iOS )
searchOptions = { hitsPerPage: 6, filters: 'company_id = '+this.companyId };
let search = autocomplete('#'+this.id, {hint: true, autoselectOnBlur: true}, [
{
source: autocomplete.sources.hits(index, searchOptions),
displayKey: 'name',
templates: {
header: '<div class="aa-headline">'+this.headline+'</div>',
suggestion: (suggestion) => {
let suggestionTemplate = (this.suggestionTemplate) ? this.suggestionTemplate : 'nameTemplate';
return this.suggestionTemplates()[suggestionTemplate](suggestion);
}
}
}
]);
search.on('autocomplete:selected',(event,suggestion,dataset) => {
this.lastSelectedValue = suggestion.name;
this.submitValue = suggestion.id;
});
//A normal change means there is hit and therefor no id
search.on('change',(e) => {
if(this.$data.lastSelectedValue != $(e.currentTarget).val())
this.submitValue = '';
}); |
Indeed, I reproduce the issue on iOS Safari; I'll need to check if we can fix that :/ |
@redox Thanks for the fast reply, it's kinda a major issue for us right now, as 60% of our customers use mobile devices to browse our site, and will depend upon if we can continue to use the service. Any idea, when i might hear back from you, so that i know if we need to look into other solutions? |
Hey guys sorry but I did push an update to solve this, see https://github.com/algolia/autocomplete.js#options. And now this is broken somehow? |
Not sure what i am looking for? Have you send the correct link ? |
@Pab89 Sorry, what I wanted to say is that autoselectOnBlur what released. If I understand well you know that, you tried to use it, but it's broken. |
@voidale You did the change to autoselectOnBlur, can you help @Pab89 here maybe? Thanks! |
@vvo Ye that is correct, i been using it to fix the problem on the iphone where nothing was selected when touched/tapped. Which autoSelectOnBlut fixed in the way that only the first hit can be selected. So still need to able to chose hits 2,3,4.. etc for it to work properly. Looking forward to a fix for this problem, as we else will need to look elsewhere for a solution that works on mobile to |
Hey, anything new here? We are in situation where we soon will need to know if we can get this script to work or need to look for another solution as this is the last fix we are waiting for before we can push our new form to production. |
@Pab89 Hey, I will take a look into this, will update soon. |
Cool thanks, i look forward for the push to be accepted. :) |
Fix gonna be released today |
Seems to me that the error still exists after the PR ? Just tryed the new 2.2.1 .min file. See https://iclaimer.com/iframe/claim-form/da/flyhjaelp-dk |
Im using safari IOS, iphone 6S |
Saw that, it's clearly not working. Basically autocomplete.js is failing on mobile, we need to investigate deeper. Can you open a new issue so we close this one? Thanks |
I tested it and it works on my side: https://www.flightscanner.org |
Thanks, any change you can send me a snippet of the code you use to implement it? Then i can try to find the difference between my and your code my self. |
@Pab89 hey, here is what I have:
|
When using the autoselect: true, it indicates that it's selecting the first suggestion, what I saw that on mobile (iOS, Safari) clicking done doesn't trigger the "Enter" event so it's doesn't select it. In android I noticed that after you see the indication that it's selected users just switch to next input.
So I really needed a way to select it on blur, I've created new option "autoselectOnBlur" very simple, could I push this as a PR? Will be nice to keep it in the code base if it's useful for others as well and easier to maintain version updates for me.
The text was updated successfully, but these errors were encountered: