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
Highlight (goTo) the first item on each keystroke #241
Comments
Hello @mileusna, You can use the Please try it and let me know how it goes. |
@TarekRaafat thank you for quick response I have tried that already but it looks like the However, I have managed to achieve what I want with small delay in
|
You should be able to use I've not tested it, but seems to me it should work. const autoSelect = new autoComplete({
data: {
src: ...,
},
resultsList: {
element: (element, data) => {
//const { input, query, matches, results } = data
autoSelect.goTo(0)
}
},
}) |
@mileusna, you're actually right using the I have tried the code below as you mentioned and it worked as expected. events: {
input: {
results: () => setTimeout(() => autoCompleteJS.goTo(0), 5),
}
} I'll look into it and get back to you if I find a more straightforward way of achieving it. @folknor same goes for your solution, it would require a delay because resultsList: {
element: (list, data) => {
setTimeout(() => autoCompleteJS.goTo(0), 5);
}
} |
Are you certain? The only thing As far as I can see, all the actions in If you are correct, you might want to test using styles like |
I just tested it and my solution works if you change this line: https://github.com/TarekRaafat/autoComplete.js/blob/master/src/controllers/listController.js#L121 by removing the Without that change, my solution works for every new search except the first time the list opens. |
@TarekRaafat In case my previous comments were unclear; the code I posted in #241 (comment) works perfectly if you remove the condition like I said in #241 (comment) |
Hey @folknor, Apologies for my delayed reply. Thanks for the clarification. I get your point. Unfortunately, there's a downside for removing the above-mentioned condition: you're going to get an error if you used the Let alone that I couldn't think of any use case that might require using the Accordingly, using a set timeout in both ways mentioned above looks more convenient for the time being until a better idea comes up. Please, let me know your thoughts. Cheers, and have a nice day! :) |
Take all the time you want, I was not concerned about any delay. I was concerned that maybe I was communicating my thoughts poorly. I think there is something here that is misunderstood. I will try to express it very clearly :-)
To me this seems cleaner. It avoids lots of setTimeout calls, and seems more convenient. I've tested it with There is either some problem I can't see, or I am not making myself understood. Thank you! |
My bad, I missed mentioning the point where exactly the error happens. The error actually occurs after using the Due to the I understand that it could be a rare case to happen, yet I believe safety is needed. Please let me know your thoughts. |
How can I highlight (goTo) to the first item in the results on each keystroke?
I tried with this, but this will work only on the first keystroke, when result box is opened.
Is there an event which will fire on earch refresh of the results?
The text was updated successfully, but these errors were encountered: