From f89616132447987cb17f881fb7e9976bd822b221 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=8D=E8=A6=81=E7=B3=96=E9=86=8B=E6=94=BE=E6=A4=92?= =?UTF-8?q?=E7=9B=90?= <62319450+Moriafly@users.noreply.github.com> Date: Sat, 10 Jan 2026 10:34:50 +0800 Subject: [PATCH] fix(Slider): ensure thumb position updates when value changes externally Slider thumb position (rawFraction) was only updated during user drag interactions. If the `value` was modified programmatically (e.g., via state hoisting or a reset button), the visual thumb position would remain stale and desynchronized from the actual value. This commit adds a check in the `value` setter to explicitly recalculate and update `rawFraction` when `isDragging` is false, ensuring the UI correctly reflects external state changes. --- .../kotlin/io/github/composefluent/component/Slider.kt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/fluent/src/commonMain/kotlin/io/github/composefluent/component/Slider.kt b/fluent/src/commonMain/kotlin/io/github/composefluent/component/Slider.kt index 238643ee..2187db1b 100644 --- a/fluent/src/commonMain/kotlin/io/github/composefluent/component/Slider.kt +++ b/fluent/src/commonMain/kotlin/io/github/composefluent/component/Slider.kt @@ -373,6 +373,11 @@ class SliderState( valueRange.endInclusive )*/ valueState = coercedValue + + // When the value is updated externally (not by user dragging), synchronize + if (!isDragging) { + rawFraction = valueToFraction(coercedValue, valueRange) + } } get() = valueState