Skip to content

A reactive notebook for Python — run reproducible experiments, query with SQL, execute as a script, deploy as an app, and version with git. Stored as pure Python. All in a modern, AI-native editor.

fix: range slider debounce edge-case (#2658)

Myles Scolnick9946211df9ba
diff --git a/frontend/src/plugins/impl/RangeSliderPlugin.tsx b/frontend/src/plugins/impl/RangeSliderPlugin.tsx
index 240c9ea103..c814c386ea 100644
--- a/frontend/src/plugins/impl/RangeSliderPlugin.tsx
+++ b/frontend/src/plugins/impl/RangeSliderPlugin.tsx
@@ -7,6 +7,7 @@ import { RangeSlider } from "../../components/ui/range-slider";
import { Labeled } from "./common/labeled";
import { cn } from "@/utils/cn";
import { prettyScientificNumber } from "@/utils/numbers";
+import { isEqual } from "lodash-es";
type T = number[];
@@ -126,6 +127,19 @@ const RangeSliderComponent = ({
setValue(nextValue);
}
}}
+ // Sometimes onValueCommit doesn't trigger
+ // see https://github.com/radix-ui/primitives/issues/1760
+ // So we also set the value on pointer/mouse up
+ onPointerUp={() => {
+ if (debounce && !isEqual(internalValue, value)) {
+ setValue(internalValue);
+ }
+ }}
+ onMouseUp={() => {
+ if (debounce && !isEqual(internalValue, value)) {
+ setValue(internalValue);
+ }
+ }}
valueMap={valueMap}
/>
{showValue && (