How to retrieve `resultsCount` on every keyDown
See original GitHub issueI have an ask to display the number of results as soon as the user types something. So, I tried pulling the power select’s public API object on every onkeydown
.
But it seems like the event onkeydown is called before https://github.com/cibernox/ember-power-select/blob/master/addon/components/power-select.js#L606 this called. So, it’s one step behind every time I try to grab the resultsCount property.
I tried a bunch of things, like setting the object as a internal property of the component, and using run.api’s later()
after some duration (sort of waiting for it to update itself), but no luck. Guess I’m setting it earlier and not resetting it once the power-select’s updateState
is called. Is there a way to grab the public object once the power-select sets its own state?
I could use the searchTerm on every onkeydown and run it through the matcher function myself manually and get a count, but that just doesn’t sound right and I’m copying the same code being executed by power-select.
Is there any other way to get an updated resultsCount on every keystroke?
Thanks!
Issue Analytics
- State:
- Created 4 years ago
- Comments:6 (6 by maintainers)
@neeleshsaxena oh, I though I had documented that action but I can see now that I didn’t. It has been there for ages. I have to update https://ember-power-select.com/docs/api-reference with that.
Tl;dr: It’s an action that you can pass to the select like
onopen
or any other action.Oh wow. Knew I was missing something. Thank you! Just need to find out how to use this registerAPI and where is it…