question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to retrieve `resultsCount` on every keyDown

See original GitHub issue

I 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:open
  • Created 4 years ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
cibernoxcommented, Jul 17, 2019

@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.

0reactions
neeleshsaxenacommented, Jul 17, 2019

Oh wow. Knew I was missing something. Thank you! Just need to find out how to use this registerAPI and where is it…

Read more comments on GitHub >

github_iconTop Results From Across the Web

Retrieve user input value from keydown - Stack Overflow
Try this: $("input").bind("keyup",function(e){ alert(String.fromCharCode(e.keyCode)); }). Demo: http://jsfiddle.net/V8hLH/.
Read more >
Element: keydown event - Web APIs | MDN
The keydown and keyup events provide a code indicating which key is pressed, while keypress indicates which character was entered. For example, ...
Read more >
How fetch the search results - Help - UiPath Community Forum
Hi When we search for something in search box we get multiple results, how to fetch that results.I have attached a image. obatined...
Read more >
Keydown is the only keyboard event we need - Mutually Human
keydown – fires when any key is pressed down, fires first, and always before the browser processes the key (e.g. inserting text, moving...
Read more >
.keydown() | jQuery API Documentation
The keydown event is sent to an element when the user presses a key on the keyboard. If the key is kept pressed,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found