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
Enhancement: Add focus event to textbox and number component #5005
Enhancement: Add focus event to textbox and number component #5005
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
🦄 change detectedThis Pull Request includes changes to the following packages.
With the following changelog entry.
Maintainers or the PR author can modify the PR title to modify this entry.
|
All the demos for this PR have been deployed at https://huggingface.co/spaces/gradio-pr-deploys/pr-5005-all-demos You can install the changes in this PR by running: pip install https://gradio-builds.s3.amazonaws.com/3af551af4b7979636a8fdd449c818450bfc39ce2/gradio-3.39.0-py3-none-any.whl |
Makes sense (surprised we didn't have this already given we have Blurable). Thanks for the PR @JodyZ0203! What if we merge |
That's a good idea. Since they are similar enough, I can merge them together. |
Hi @JodyZ0203 thanks for the contribution! Would you be interested in implementing the suggested changes? |
Hi @abidlabs , I'm currently working on the suggested changes. Aiming to get PR out this weekend. Thanks! |
@abidlabs @aliabid94 Changes are ready! |
Thanks @JodyZ0203! Would you just be able to resolve the merge conflict, and then happy to take another look |
Hi @abidlabs! Merge conflict resolved. It's ready for another look. Thanks! |
@@ -22,6 +23,15 @@ | |||
dispatch("input"); | |||
} | |||
} | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no need for event listener methods if they just dispatch - on:blur and on:focus is sufficient.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That make sense.
function handle_focus(e: FocusEvent){ | ||
dispatch("focus"); | ||
showOptions = !showOptions; | ||
if (showOptions) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there's an existing handleFocus method, that is pretty identical except you changed
filtered = choices;
to
inputValue = "";
any reason for this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah we should keep filtered = choices;
I believe, otherwise, it'll revert some of the fixes in #5039
made the fixes, should be ready to merge. Thanks for this @JodyZ0203 ! |
Thanks again @JodyZ0203! Merging |
🎉 Chromatic build completed! There are 4 visual changes to review. |
Thank you! @abidlabs @aliabid94 |
Description
event.py
and combined Blurrable with Focusable.focus()
event.Closes: #(issue)
This PR fixes #4817
🎯 PRs Should Target Issues
Before your create a PR, please check to see if there is an existing issue for this change. If not, please create an issue before you create this PR, unless the fix is very small.
Not adhering to this guideline will result in the PR being closed.
Tests
PRs will only be merged if tests pass on CI. To run the tests locally, please set up your Gradio environment locally and run the tests:
bash scripts/run_all_tests.sh
You may need to run the linters:
bash scripts/format_backend.sh
andbash scripts/format_frontend.sh
Test with
Demo
Gradio.Component.Focus.mov
Focusable.on.Dropdown.and.ColorPicker.mov