Skip to content

Textbox with trigger=true clears itself after submitting value #150

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

Closed
lo5 opened this issue Sep 23, 2020 · 7 comments · Fixed by #746
Closed

Textbox with trigger=true clears itself after submitting value #150

lo5 opened this issue Sep 23, 2020 · 7 comments · Fixed by #746
Assignees
Labels
bug Bug in code ui Related to UI
Milestone

Comments

@lo5
Copy link
Member

lo5 commented Sep 23, 2020

Q SDK Version, OS
0.6.0

Steps To Reproduce
Run this example: https://github.com/h2oai/qd/blob/master/py/examples/table_filter_backend.py

Actual behavior
Search field is cleared as soon as you type.

Expected behavior
Search field should not be cleared.

@lo5 lo5 added ui Related to UI bug Bug in code labels Sep 23, 2020
@lo5 lo5 added this to the 2020 Q3 milestone Sep 23, 2020
@mturoci
Copy link
Collaborator

mturoci commented Sep 24, 2020

Since trigger submits the value and rerenders the component, there is no way as of now to keep the state on client. I consider clearing the field after submitting a normal UX (visual feedback something happened) - it makes sense in pig latin example. However, if you don't want to clear the field after submit, you can specify the textbox like this:

ui.textbox(name='search', label='Search', placeholder='Enter a keyword...', trigger=True, value=q.args.search)

@mturoci
Copy link
Collaborator

mturoci commented Sep 24, 2020

The only UX problem with that though is losing focus on search field itself. We can probably add focus prop that would focus the component on render.

cc @lo5

@lo5
Copy link
Member Author

lo5 commented Sep 24, 2020

Having to set value=q.args.search is extra work (and ugly) from the app author's perspective.

One way to address this is to make each form component update its value in the local copy of the card.
Today, it only sets the changed value in args and either syncs or gets submitted when some other component invokes a sync.

if, say, the textbox stored its value in the local copy of the card, then the caller doesn't need to explicitly set the value on the roundtrip.

@lo5
Copy link
Member Author

lo5 commented Sep 24, 2020

Let's table this for a while. I need some time to mull it over.

@lo5
Copy link
Member Author

lo5 commented Sep 24, 2020

We can probably add focus prop that would focus the component on render.

This would be useful. How would you achieve this exactly?

@mturoci
Copy link
Collaborator

mturoci commented Sep 24, 2020

This would be useful. How would you achieve this exactly?

We can add a ref to the textbox and simply call ref.current.focus() in init function.

@mturoci
Copy link
Collaborator

mturoci commented Sep 24, 2020

Note that this is far broader problem than just textbox. It clears the value in same manner for every component with trigger=True.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Bug in code ui Related to UI
Projects
None yet
2 participants