what-input
what-input copied to clipboard
expose `doUpdate` to API
In cases where one wants to prevent default key events (e.g. stopping, preventDefault), it would be necessary to call doUpdate('intent')
manually from the outside as whatInput listeners will not be reached.
Interesting! That sounds pretty simple to implement. Do you have a scenario that I could create locally to test against when I add this?
Hi, @dailyraisin @ten1seven I am interested in the same feature. I use React and here is my scenario:
-
onKeyDown
handler is called on acomponent A
- inside this handler, there is a quite big logic, which at the end finds a particular child
component B
and focuses it -
onFocus
handler ofcomponent B
is called where it is checked if thewhatInput.ask() === 'keyboard'
, we will get herefalse
- and only afterward the
window.addEventListener('keydown')
fromwhat-input
lib is called and update a state tokeyboard
but it's too late for me.
It would be very useful to have access to function like setInput
, so I can call on initial onKeyDown
handler of component B
and update the state accordingly.
@ten1seven let me know what you think
Hi @sophieH29, I'm digging into this request. Are you push a specific input to what-input and trigger a doUpdate
? Something like this?
whatInput.setInput('keyboard');
Hi @ten1seven, I would rather say just to make current function setInput
public, so I will be able to call it onKeyDown event and update state, like
onKeyDown = (ev) => {
...
whatInput.setInput(ev)
...
}
@ten1seven do you plan to make this update to the library?