-
-
Notifications
You must be signed in to change notification settings - Fork 664
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
Events such as keydown and keyup are not triggered by an ui.input when not assigned directly upon creation #4154
Comments
Interesting observation, @Alyxion! This handler does not work: i = ui.input()
ui.timer(1.0, lambda: i.on('keydown', ui.notify), once=True) But button click handlers can be assigned this way. So it's not a general event registration problem. b = ui.button()
ui.timer(1.0, lambda: b.on('click', ui.notify), once=True) And as far as I can tell, the event listeners are registered correctly and sent to the client. But there is no websocket message sent to the server when a key is pressed. Very strange! |
Does anyone have an idea how to approach this issue? I wonder if it is caused by Vue or Quasar and the way they handle UI updates. But other elements, even similar ones like |
This works: @ui.page('/')
async def page():
i = ui.input()
await asyncio.sleep(1.0)
i.on('keydown', ui.notify) But this doesn't: @ui.page('/')
async def page():
i = ui.input()
await asyncio.sleep(1.0)
i.on('keydown', ui.notify) So it really depends on whether the event handler is part of the initial HTTP response, or sent via an update message later. |
I've got the feeling that the reason for this problem is related to #4087, where we noticed that Maybe this problem needs to be addressed upstream. A quick look into https://github.com/quasarframework/quasar/issues/ and https://github.com/quasarframework/quasar/discussions/ didn't yield any insights though. |
Description
During the development of a Typeahead component which attaches itself visually to the bottom of an ui.input field to (later) show search result data from a DB, i stumbled over a potential bug when modifying certain event_listeners such as
keydown
andkeyup
via theelement.on
method "post creation".Situation:
.on("focus", handle_focus)
and a blur_handler is setup viaon("blur", handle_blur)
handle_focus
the.on("keydown", handle_keydown)
is assigned to track cursor key presseshandle_blur
the event listener is removed again..on
yet there is a helper class involved which "cleans up again" / can unassign event listeners, but that just as side note and has no impact on this report / test as you can see in the example code attached below.If a "keypress" or "keyup" listener is assigned later and not directly upon creation of the input field, so e.g. delayed by a timer or an event, then the handlers will never be called. If they are assigned directly upon creation, so before everything goes through the websocket from Python to JS, then they work though.
If I assign the same events directly via JavaScript to the DOM element w/ help of the new
getHtmlElement
function though then everything works perfectly fine. Thus there seems to be some synchronization kind of issue for certain events. A delayed assignedblur
event just for example works like a charm.The text was updated successfully, but these errors were encountered: