@@ -12,6 +12,7 @@ import React, {
1212 useContext ,
1313 useEffect ,
1414 useMemo ,
15+ useRef ,
1516 useState ,
1617 type FocusEvent ,
1718 type ForwardedRef ,
@@ -42,7 +43,7 @@ import ListBox, {
4243 type ListBoxSize ,
4344 type ListBoxType ,
4445} from '../ListBox' ;
45- import mergeRefs from '../../tools/mergeRefs' ;
46+ import { mergeRefs } from '../../tools/mergeRefs' ;
4647import { deprecate } from '../../prop-types/deprecate' ;
4748import { usePrefix } from '../../internal/usePrefix' ;
4849import { FormContext } from '../FluidForm' ;
@@ -510,7 +511,12 @@ const Dropdown = React.forwardRef(
510511 setIsFocused ( evt . type === 'focus' && ! selectedItem ? true : false ) ;
511512 } ;
512513
513- const mergedRef = mergeRefs ( toggleButtonProps . ref , ref ) ;
514+ const buttonRef = useRef < HTMLButtonElement > ( null ) ;
515+ const mergedRef = mergeRefs < HTMLButtonElement > (
516+ toggleButtonProps . ref ,
517+ ref ,
518+ buttonRef
519+ ) ;
514520
515521 const [ currTimer , setCurrTimer ] = useState < NodeJS . Timeout > ( ) ;
516522
@@ -563,7 +569,7 @@ const Dropdown = React.forwardRef(
563569 // NOTE: does not prevent click
564570 evt . preventDefault ( ) ;
565571 // focus on the element as per readonly input behavior
566- mergedRef ? .current ?. focus ( ) ;
572+ buttonRef . current ?. focus ( ) ;
567573 } ,
568574 onKeyDown : ( evt : React . KeyboardEvent < HTMLButtonElement > ) => {
569575 const selectAccessKeys = [ 'ArrowDown' , 'ArrowUp' , ' ' , 'Enter' ] ;
@@ -578,7 +584,6 @@ const Dropdown = React.forwardRef(
578584 onKeyDown : onKeyDownHandler ,
579585 } ;
580586 }
581- // eslint-disable-next-line react-hooks/exhaustive-deps -- https://github.com/carbon-design-system/carbon/issues/20071
582587 } , [ readOnly , onKeyDownHandler ] ) ;
583588
584589 const menuProps = useMemo (
0 commit comments