Prevent slider from going past bounds (#2222)

## Description

#1900 updated how the value was handled in pv-slider, and
unintentionally removed bounds protection. This restores bounds
protection.

Unfortunately, there is an edge case that might be rather difficult to
solve. If the slider is already at the min/max, you can enter a number
through the text field, and while the value won't actually update, the
text field keeps the entered value, likely because the model value
didn't change, and therefore, a rerender isn't triggered. However, this
is an edge case that I doubt many people will actually encounter, so we
should still ship this.

Fixes #2221.

## Meta

Merge checklist:
- [x] Pull Request title is [short, imperative
summary](https://cbea.ms/git-commit/) of proposed changes
- [x] The description documents the _what_ and _why_
- [ ] If this PR changes behavior or adds a feature, user documentation
is updated
- [ ] If this PR touches photon-serde, all messages have been
regenerated and hashes have not changed unexpectedly
- [ ] If this PR touches configuration, this is backwards compatible
with settings back to v2025.3.2
- [ ] If this PR touches pipeline settings or anything related to data
exchange, the frontend typing is updated
- [x] If this PR addresses a bug, a regression test for it is added
This commit is contained in:
Gold856
2025-12-07 12:49:14 -05:00
committed by GitHub
parent 9e45e8b80a
commit d44d9fbbeb
2 changed files with 46 additions and 1 deletions

View File

@@ -27,7 +27,13 @@ function debounce(func: (...args: any[]) => void, wait: number) {
}
const debouncedEmit = debounce((v: number) => {
emit("update:modelValue", v);
if (v < props.min) {
emit("update:modelValue", props.min);
} else if (v > props.max) {
emit("update:modelValue", props.max);
} else {
emit("update:modelValue", v);
}
}, 20);
const localValue = computed({