@@ -20,6 +20,7 @@ import {
2020 strAsDate ,
2121} from '../utils/calendar/helpers' ;
2222import { captureCSSForPortal } from '../utils/calendar/cssVariables' ;
23+ import ResizeDetector from '../utils/ResizeDetector' ;
2324import '../components/css/datepickers.css' ;
2425
2526const DatePickerRange = ( {
@@ -104,6 +105,8 @@ const DatePickerRange = ({
104105 const containerRef = useRef < HTMLDivElement > ( null ) ;
105106 const startInputRef = useRef < HTMLInputElement | null > ( null ) ;
106107 const endInputRef = useRef < HTMLInputElement | null > ( null ) ;
108+ const startAutosizeRef = useRef < any > ( null ) ;
109+ const endAutosizeRef = useRef < any > ( null ) ;
107110 const calendarRef = useRef < CalendarHandle > ( null ) ;
108111 const hasPortal = with_portal || with_full_screen_portal ;
109112
@@ -128,6 +131,12 @@ const DatePickerRange = ({
128131 setEndInputValue ( formatDate ( internalEndDate , display_format ) ) ;
129132 } , [ internalEndDate , display_format ] ) ;
130133
134+ const handleResize = useCallback ( ( ) => {
135+ startAutosizeRef . current ?. updateInputWidth ?.( ) ;
136+ endAutosizeRef . current ?. updateInputWidth ?.( ) ;
137+ } , [ ] ) ;
138+
139+
131140 useEffect ( ( ) => {
132141 // Controls when setProps is called. Basically, whenever internal state
133142 // diverges from props (i.e., user interaction)
@@ -313,6 +322,10 @@ const DatePickerRange = ({
313322 ) ;
314323
315324 return (
325+ < ResizeDetector
326+ onResize = { handleResize }
327+ targets = { [ containerRef ] }
328+ >
316329 < div className = "dash-datepicker" ref = { containerRef } >
317330 < Popover . Root
318331 open = { ! disabled && isCalendarOpen }
@@ -335,6 +348,7 @@ const DatePickerRange = ({
335348 } }
336349 >
337350 < AutosizeInput
351+ ref = { startAutosizeRef }
338352 inputRef = { node => {
339353 startInputRef . current = node ;
340354 } }
@@ -356,6 +370,7 @@ const DatePickerRange = ({
356370 />
357371 < ArrowIcon className = "dash-datepicker-range-arrow" />
358372 < AutosizeInput
373+ ref = { endAutosizeRef }
359374 inputRef = { node => {
360375 endInputRef . current = node ;
361376 } }
@@ -458,6 +473,7 @@ const DatePickerRange = ({
458473 </ Popover . Portal >
459474 </ Popover . Root >
460475 </ div >
476+ </ ResizeDetector >
461477 ) ;
462478} ;
463479
0 commit comments