22import * as React from 'react' ;
33import * as ReactDOM from 'react-dom' ;
44import { ownerWindow , ownerDocument } from '@base-ui-components/utils/owner' ;
5- import { isWebKit } from '@base-ui-components/utils/detectBrowser' ;
6- import { useValueAsRef } from '@base-ui-components/utils/useValueAsRef' ;
5+ import { isFirefox , isWebKit } from '@base-ui-components/utils/detectBrowser' ;
76import { useStableCallback } from '@base-ui-components/utils/useStableCallback' ;
87import { useTimeout } from '@base-ui-components/utils/useTimeout' ;
98import type { BaseUIComponentProps , HTMLProps } from '../../utils/types' ;
@@ -44,7 +43,6 @@ export const NumberFieldScrubArea = React.forwardRef(function NumberFieldScrubAr
4443 setIsScrubbing,
4544 disabled,
4645 readOnly,
47- value,
4846 inputRef,
4947 incrementValue,
5048 getStepAmount,
@@ -53,8 +51,6 @@ export const NumberFieldScrubArea = React.forwardRef(function NumberFieldScrubAr
5351 valueRef,
5452 } = useNumberFieldRootContext ( ) ;
5553
56- const latestValueRef = useValueAsRef ( value ) ;
57-
5854 const scrubAreaRef = React . useRef < HTMLSpanElement > ( null ) ;
5955
6056 const isScrubbingRef = React . useRef ( false ) ;
@@ -149,21 +145,20 @@ export const NumberFieldScrubArea = React.forwardRef(function NumberFieldScrubAr
149145 let cumulativeDelta = 0 ;
150146
151147 function handleScrubPointerUp ( event : PointerEvent ) {
152- try {
153- // Avoid errors in testing environments.
154- // Firefox needs a small delay here when soft-clicking as the pointer
155- // lock will not release otherwise.
156- exitPointerLockTimeout . start ( 20 , ( ) => {
148+ // Firefox needs a small delay here when soft-clicking as the pointer
149+ // lock will not release otherwise.
150+ exitPointerLockTimeout . start ( isFirefox ? 20 : 0 , ( ) => {
151+ try {
157152 ownerDocument ( scrubAreaRef . current ) . exitPointerLock ( ) ;
158- } ) ;
159- } finally {
160- isScrubbingRef . current = false ;
161- onScrubbingChange ( false , event ) ;
162- onValueCommitted (
163- lastChangedValueRef . current ?? valueRef . current ,
164- createGenericEventDetails ( REASONS . scrub , event ) ,
165- ) ;
166- }
153+ } finally {
154+ isScrubbingRef . current = false ;
155+ onScrubbingChange ( false , event ) ;
156+ onValueCommitted (
157+ lastChangedValueRef . current ?? valueRef . current ,
158+ createGenericEventDetails ( REASONS . scrub , event ) ,
159+ ) ;
160+ }
161+ } ) ;
167162 }
168163
169164 function handleScrubPointerMove ( event : PointerEvent ) {
@@ -210,9 +205,8 @@ export const NumberFieldScrubArea = React.forwardRef(function NumberFieldScrubAr
210205 [
211206 disabled ,
212207 readOnly ,
213- isScrubbing ,
214208 incrementValue ,
215- latestValueRef ,
209+ isScrubbing ,
216210 getStepAmount ,
217211 inputRef ,
218212 onScrubbingChange ,
0 commit comments