@@ -234,11 +234,11 @@ describe("FlatSlider", () => {
234234 const { host, root } = renderInto (
235235 < FlatSlider
236236 label = "Opacity"
237- value = { 50 }
237+ value = { 10 }
238238 min = { 0 }
239239 max = { 100 }
240240 tier = "explicitCustom"
241- displayValue = "50 %"
241+ displayValue = "10 %"
242242 onCommit = { onCommit }
243243 /> ,
244244 ) ;
@@ -249,6 +249,7 @@ describe("FlatSlider", () => {
249249 } ) ;
250250 act ( ( ) => {
251251 track . dispatchEvent ( new MouseEvent ( "pointerdown" , { bubbles : true , clientX : 100 } ) ) ;
252+ track . dispatchEvent ( new MouseEvent ( "pointerup" , { bubbles : true , clientX : 100 } ) ) ;
252253 } ) ;
253254 expect ( onCommit ) . toHaveBeenCalledWith ( 50 ) ;
254255 act ( ( ) => root . unmount ( ) ) ;
@@ -276,12 +277,13 @@ describe("FlatSlider", () => {
276277 track . dispatchEvent (
277278 new MouseEvent ( "pointerdown" , { bubbles : true , clientX : 20 , clientY : 18 } ) ,
278279 ) ;
280+ track . dispatchEvent ( new MouseEvent ( "pointerup" , { bubbles : true , clientX : 20 } ) ) ;
279281 } ) ;
280282 expect ( onCommit ) . toHaveBeenCalledWith ( 10 ) ;
281283 act ( ( ) => root . unmount ( ) ) ;
282284 } ) ;
283285
284- it ( "commits continuously while dragging, not just on the initial pointerdown " , ( ) => {
286+ it ( "tracks the knob instantly on every pointermove during a drag (draft state) " , ( ) => {
285287 const onCommit = vi . fn ( ) ;
286288 const { host, root } = renderInto (
287289 < FlatSlider
@@ -304,25 +306,73 @@ describe("FlatSlider", () => {
304306 new PointerEvent ( "pointerdown" , { bubbles : true , clientX : 20 , pointerId : 1 } ) ,
305307 ) ;
306308 } ) ;
307- expect ( onCommit ) . toHaveBeenLastCalledWith ( 10 ) ;
309+ // Instant, un-debounced knob feedback via aria-valuenow (draft state) —
310+ // this must update on every pointermove regardless of the commit debounce.
311+ expect ( track . getAttribute ( "aria-valuenow" ) ) . toBe ( "10" ) ;
308312 act ( ( ) => {
309313 track . dispatchEvent (
310314 new PointerEvent ( "pointermove" , { bubbles : true , clientX : 160 , pointerId : 1 } ) ,
311315 ) ;
312316 } ) ;
313- expect ( onCommit ) . toHaveBeenLastCalledWith ( 80 ) ;
317+ expect ( track . getAttribute ( "aria-valuenow" ) ) . toBe ( "80" ) ;
314318 act ( ( ) => {
315319 track . dispatchEvent (
316320 new PointerEvent ( "pointermove" , { bubbles : true , clientX : 100 , pointerId : 1 } ) ,
317321 ) ;
318322 } ) ;
319- expect ( onCommit ) . toHaveBeenLastCalledWith ( 50 ) ;
323+ expect ( track . getAttribute ( "aria-valuenow" ) ) . toBe ( "50" ) ;
320324 act ( ( ) => {
321325 track . dispatchEvent ( new PointerEvent ( "pointerup" , { bubbles : true , pointerId : 1 } ) ) ;
322326 } ) ;
323327 act ( ( ) => root . unmount ( ) ) ;
324328 } ) ;
325329
330+ it ( "coalesces rapid drag commits to only the final value on release, not every step" , ( ) => {
331+ const onCommit = vi . fn ( ) ;
332+ const { host, root } = renderInto (
333+ < FlatSlider
334+ label = "Opacity"
335+ value = { 5 }
336+ min = { 0 }
337+ max = { 100 }
338+ tier = "explicitCustom"
339+ displayValue = "5%"
340+ onCommit = { onCommit }
341+ /> ,
342+ ) ;
343+ const track = host . querySelector < HTMLElement > ( '[data-flat-slider-track="true"]' ) ;
344+ if ( ! track ) throw new Error ( "expected a track element" ) ;
345+ Object . defineProperty ( track , "getBoundingClientRect" , {
346+ value : ( ) => ( { left : 0 , width : 200 , top : 0 , height : 20 , right : 200 , bottom : 20 } ) ,
347+ } ) ;
348+ act ( ( ) => {
349+ track . dispatchEvent (
350+ new PointerEvent ( "pointerdown" , { bubbles : true , clientX : 20 , pointerId : 1 } ) ,
351+ ) ;
352+ track . dispatchEvent (
353+ new PointerEvent ( "pointermove" , { bubbles : true , clientX : 160 , pointerId : 1 } ) ,
354+ ) ;
355+ track . dispatchEvent (
356+ new PointerEvent ( "pointermove" , { bubbles : true , clientX : 100 , pointerId : 1 } ) ,
357+ ) ;
358+ } ) ;
359+ // None of the rapid intermediate positions (10, 80) have committed yet —
360+ // only the debounce timer or the pointerup flush should ever call onCommit.
361+ expect ( onCommit ) . not . toHaveBeenCalled ( ) ;
362+ act ( ( ) => {
363+ // Real pointerup events always carry the pointer's true release position
364+ // (matches the last pointermove) — the handler recomputes from this
365+ // rather than trusting a possibly-stale `draft` closure.
366+ track . dispatchEvent (
367+ new PointerEvent ( "pointerup" , { bubbles : true , clientX : 100 , pointerId : 1 } ) ,
368+ ) ;
369+ } ) ;
370+ // Release flushes immediately with the LAST position only.
371+ expect ( onCommit ) . toHaveBeenCalledTimes ( 1 ) ;
372+ expect ( onCommit ) . toHaveBeenCalledWith ( 50 ) ;
373+ act ( ( ) => root . unmount ( ) ) ;
374+ } ) ;
375+
326376 it ( "ignores pointermove once a drag has ended (pointer capture released)" , ( ) => {
327377 const onCommit = vi . fn ( ) ;
328378 const { host, root } = renderInto (
0 commit comments