Skip to content
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

clearing value of ui.input() does not work on 2nd try #1088

Closed
eshyun opened this issue Jun 26, 2023 · 5 comments
Closed

clearing value of ui.input() does not work on 2nd try #1088

eshyun opened this issue Jun 26, 2023 · 5 comments
Labels
bug Something isn't working
Milestone

Comments

@eshyun
Copy link

eshyun commented Jun 26, 2023

Description

Code to reproduce:

from nicegui import ui

prompt = ui.input().on('keypress.enter', lambda: prompt.set_value(None))

ui.run(port=8889)
  1. Enter some text and just press 'Enter' key, then the value of prompt element will be delete on the first try
  2. Enter any text again and press 'Enter' key again to find that nothing happens, leaving the input value intact.

Alternatively, the official demo at Input Styling can be used to reproduce the issue. Just click 'delete' icon more than twice from the 3rd example.

This issue is new in version 1.2.22. Everything is okay in version 1.2.21 and older.

@falkoschindler falkoschindler added this to the 1.2.23 milestone Jun 26, 2023
@falkoschindler falkoschindler added the bug Something isn't working label Jun 26, 2023
@falkoschindler
Copy link
Contributor

Thanks for reporting this bug, @eshyun!
Luckily, there's already a fix (see #1071) that will be released with version 1.2.23 shortly. 🙂

@falkoschindler
Copy link
Contributor

@eshyun, by the way: I love your short and precise bug report! That's a great starting point for further investigating the problem.

And another thought about your key event: "keypress" is depricated. So you better use "keydown" or "keyup".

@eshyun
Copy link
Author

eshyun commented Jun 27, 2023

@falkoschindler , thanks for fixing the bug so quickly.

Regarding the deprecation of keypress, I've tried to work around a issue with keydown/keyup event. In CJK IME, especially Korean, keydown event does not properly handle the last composing character, and thus, when I press Enter key it triggers keydown event twice. Alt sequence might be the similar issue in the western world. This is not the case with keypress event. One workaround is to use isComing flag along with keydown event, however, it's a lot more complicated.
Thanks for bringing this up anyway. I honestly didn't know that it's been deprecated as I'm not from frontend world.

@tjongsma
Copy link

@falkoschindler, I'm currently having the exact same problem with ui.editor. editor.set_value(None) works once and then after that not anymore. Any suggestions for this one?

@falkoschindler
Copy link
Contributor

Thanks for letting us know, @tjongsma!
I created issue #3217 for tracking this bug.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants