@@ -29,6 +29,7 @@ function Navigation(
2929 className,
3030 title,
3131 fixedTitle = false ,
32+ width = 240 ,
3233 minWidth = 240 ,
3334 maxWidth = 540 ,
3435 disableResize = false ,
@@ -39,13 +40,13 @@ function Navigation(
3940) {
4041 const navigationRef = useRef < HTMLDivElement | null > ( null )
4142 const mergedRef = useMergeRefs < HTMLDivElement > ( navigationRef , forwardedRef )
42- const [ width , setWidth ] = useState < number > ( minWidth )
43+ const [ currentWidth , setCurrentWidth ] = useState < number > ( _ . clamp ( width , minWidth , maxWidth ) )
4344 const [ isDragging , setIsDragging ] = useState ( false )
4445
4546 const handleMouseMove = useCallback ( ( e : MouseEvent ) => {
4647 if ( disableResize ) { return }
4748
48- window . requestAnimationFrame ( ( ) => setWidth (
49+ window . requestAnimationFrame ( ( ) => setCurrentWidth (
4950 _ . clamp (
5051 e . pageX - navigationRef . current ?. offsetLeft ,
5152 minWidth ,
@@ -68,8 +69,12 @@ function Navigation(
6869 } , [ ] )
6970
7071 useEffect ( ( ) => {
71- onChangeWidth ( width )
72- } , [ width , onChangeWidth ] )
72+ onChangeWidth ( currentWidth )
73+ } , [ currentWidth , onChangeWidth ] )
74+
75+ useEffect ( ( ) => {
76+ setCurrentWidth ( _ . clamp ( width , minWidth , maxWidth ) )
77+ } , [ width , minWidth , maxWidth ] )
7378
7479 useEffect ( ( ) => {
7580 if ( isDragging ) {
@@ -86,7 +91,7 @@ function Navigation(
8691 ref = { mergedRef }
8792 style = { style }
8893 className = { className }
89- width = { width }
94+ width = { currentWidth }
9095 data-testid = { testId }
9196 isDragging = { isDragging }
9297 >
0 commit comments