Clamps values for typeable slider input when out of range (#2380)

* warning for slider type input

* fix value on blur

* remove unnecesary classes

* update changelog

* Update CHANGELOG.md
This commit is contained in:
Dawood Khan 2022-10-05 14:30:40 -04:00 committed by GitHub
parent a03d0ebe7c
commit b59c45160d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 0 deletions

View File

@ -53,6 +53,7 @@ No changes to highlight.
* Copy changelog file in website docker by [@aliabd](https://github.com/aliabd) in [PR 2384](https://github.com/gradio-app/gradio/pull/2384) * Copy changelog file in website docker by [@aliabd](https://github.com/aliabd) in [PR 2384](https://github.com/gradio-app/gradio/pull/2384)
* Lets users provide a `gr.update()` dictionary even if post-processing is diabled [@abidlabs](https://github.com/abidlabs) in [PR 2385](https://github.com/gradio-app/gradio/pull/2385) * Lets users provide a `gr.update()` dictionary even if post-processing is diabled [@abidlabs](https://github.com/abidlabs) in [PR 2385](https://github.com/gradio-app/gradio/pull/2385)
* Fix bug where errors would cause apps run in reload mode to hang forever by [@freddyaboulton](https://github.com/freddyaboulton) in [PR 2394](https://github.com/gradio-app/gradio/pull/2394) * Fix bug where errors would cause apps run in reload mode to hang forever by [@freddyaboulton](https://github.com/freddyaboulton) in [PR 2394](https://github.com/gradio-app/gradio/pull/2394)
* Fix bug where new typeable slider doesn't respect the minimum and maximum values [@dawoodkhan82](https://github.com/dawoodkhan82) in [PR 2380](https://github.com/gradio-app/gradio/pull/2380)
## Contributors Shoutout: ## Contributors Shoutout:
No changes to highlight. No changes to highlight.

View File

@ -21,6 +21,7 @@
const dispatch = createEventDispatcher<{ change: number }>(); const dispatch = createEventDispatcher<{ change: number }>();
$: dispatch("change", value); $: dispatch("change", value);
const clamp = () => (value = Math.min(Math.max(value, minimum), maximum));
</script> </script>
<div class="w-full flex flex-col "> <div class="w-full flex flex-col ">
@ -34,6 +35,7 @@
bind:value bind:value
min={minimum} min={minimum}
max={maximum} max={maximum}
on:blur={clamp}
{step} {step}
{disabled} {disabled}
/> />