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

Add enter handler for the textbox #407

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

VijithaEkanayake-zz
Copy link

Fixes: #372

Copy link
Collaborator

@mturoci mturoci left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good job @VijithaEkanayake! A few comments from me.

Comment on lines 25 to 29
elif q.args.enter_key_handler:
q.page['example'].items = [
ui.text(f'textbox_enter_key_handler={q.args.enter_key_handler}'),
ui.button(name='show_form', label='Back', primary=True),
]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess a better scenario would be to show every input filled (add the enter handler logic to q.args.show if branch instead), not just enter handler as the enter submits the whole form, not just a single item and might cause confusion for some people. @lo5 wdyt.

@@ -36,6 +41,7 @@ async def serve(q: Q):
ui.textbox(name='textbox_placeholder', label='With placeholder', placeholder='I need some input'),
ui.textbox(name='textbox_disabled_placeholder', label='Disabled with placeholder', disabled=True,
placeholder='I am disabled'),
ui.textbox(name='enter_key_handler', label='Submits the textbox value on Enter key', icon='Search'),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Go with convention format: textbox_*** so textbox_enter or something for your case.

ui/src/textbox.test.tsx Outdated Show resolved Hide resolved
ui/src/textbox.test.tsx Outdated Show resolved Hide resolved
ui/src/textbox.test.tsx Outdated Show resolved Hide resolved
ui/src/textbox.tsx Outdated Show resolved Hide resolved
ui/src/textbox.tsx Outdated Show resolved Hide resolved
Copy link
Member

@lo5 lo5 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The implementation unconditionally calls the keyup handler. We need a properly-named attribute on the textbox that conditionally enables this behavior.

@mturoci - this might conflict with #348?

@mturoci
Copy link
Collaborator

mturoci commented Dec 18, 2020

@mturoci - this might conflict with #348?

Yes, I suppose. I suggest addressing both issues in this PR.

VijithaEkanayake and others added 3 commits December 18, 2020 16:45
Co-authored-by: mturoci <64769322+mturoci@users.noreply.github.com>
Co-authored-by: mturoci <64769322+mturoci@users.noreply.github.com>
The implementation conditionally calls the keyup handler based on the values of the submit attribute.
Fixes: #372
@VijithaEkanayake-zz
Copy link
Author

VijithaEkanayake-zz commented Dec 18, 2020

The implementation unconditionally calls the keyup handler. We need a properly-named attribute on the textbox that conditionally enables this behavior.

@mturoci - this might conflict with #348?

@lo5 @mturoci Introduced a new attribute called submit to the textbox to conditionally call the keyUp handler and addressed the requested changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add enter handler for textbox
4 participants