-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Allow empty value in gr.Number #8974
Conversation
🪼 branch checks and previews
Install Gradio from this PR pip install https://gradio-builds.s3.amazonaws.com/4671c89b14fb3012a13b92802019e60a368e2960/gradio-4.40.0-py3-none-any.whl Install Gradio Python Client from this PR pip install "gradio-client @ git+https://github.com/gradio-app/gradio@4671c89b14fb3012a13b92802019e60a368e2960#subdirectory=client/python" Install Gradio JS Client from this PR npm install https://gradio-builds.s3.amazonaws.com/4671c89b14fb3012a13b92802019e60a368e2960/gradio-client-1.4.0.tgz |
🦄 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.
|
Tests failing, will change implementation |
|
||
if self.minimum is not None and payload < self.minimum: | ||
raise Error(f"Value {payload} is less than minimum value {self.minimum}.") | ||
elif self.maximum is not None and payload > self.maximum: | ||
raise Error( | ||
f"Value {payload} is greater than maximum value {self.maximum}." | ||
) | ||
|
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.
IIUC this change should have no effect since the first branch terminates in a return statement, am I misunderstanding?
@@ -96,7 +102,7 @@ | |||
border: var(--input-border-width) solid var(--input-border-color); | |||
border-radius: var(--input-radius); | |||
} | |||
input[type="number"] { | |||
input[type="text"] { |
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 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.
I don't think this change should be needed since at least according to the original issue, it is in theory possible to set a numeric field blank:
Currently, I can set the value to Callable, where Callable returns None. I have tested this, and the frontend displays it as blank, which aligns with my requirements.
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.
This means that browsers won't treat this field as numeric. On Desktop it means we'll lose these:
Thats a good point, we don't want to lose that :/
In light of your comment I'll close the issue in which case. Thanks for reviewing nonetheless! |
Description
We should allow empty values to be shown on the frontend in gr.Number when its None/null. I've not changed the data type of
value
itself but rather created a new variable which is used for displaying the value as a empty string when the value is null, and it updates whenever value updates.Demo:
Closes: #6728
🎯 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