Add blur event to textbox and number#2448
Conversation
|
All the demos for this PR have been deployed at https://huggingface.co/spaces/gradio-pr-deploys/pr-2448-all-demos |
|
lgtm |
|
Is this really a thing people want to do? |
It could be a useful way to get a .change()-like effect that doesn't fire with every character that is typed.
import gradio as gr
import time
with gr.Blocks() as demo:
a = gr.Number()
c = gr.Number()
a.blur(lambda x:x, a, c)
demo.launch() |
But the user has to click out of the box to trigger it, and they may not be aware of it. Personally no strong feeling whether or not to merge this. |
|
The use case that I envision here is a form with multiple textboxes / numbers, and you want the output to update as a user updates the values of the form components. It's nice for the user to be able flow between the form components without having to click a submit button. Imo it doesn't the surface area too much or in any significantly new directions, so would be in favor of merging once it's fully working. |
|
@abidlabs should work for number now. |
abidlabs
left a comment
There was a problem hiding this comment.
Works great thanks @dawoodkhan82! LGTM
|
This would be better as a Note: Although our event is called |
|
Right, I was considering re-implementing the change event by using |
|
Yeah I think we shouldn't change the |
|
Sorry, I meant that this blur functionality is better covered by the native change DOM event, not that we should alter our change event. One benefit of the native change event is that it doesn't trigger when the value has not changed even if the user focuses in and out of an input. |
Description
Add blur event. Triggered when user clicks out of textbox.
Screen.Recording.2022-10-11.at.3.39.22.PM.mov
Please include:
Closes: #2449
Checklist:
A note about the CHANGELOG
Hello 👋 and thank you for contributing to Gradio!
All pull requests must update the change log located in CHANGELOG.md, unless the pull request is labeled with the "no-changelog-update" label.
Please add a brief summary of the change to the Upcoming Release > Full Changelog section of the CHANGELOG.md file and include
a link to the PR (formatted in markdown) and a link to your github profile (if you like). For example, "* Added a cool new feature by
[@myusername](link-to-your-github-profile)in[PR 11111](https://github.com/gradio-app/gradio/pull/11111)".If you would like to elaborate on your change further, feel free to include a longer explanation in the other sections.
If you would like an image/gif/video showcasing your feature, it may be best to edit the CHANGELOG file using the
GitHub web UI since that lets you upload files directly via drag-and-drop.