@@ -3,8 +3,7 @@ import {isFocusable} from '@primer/behaviors/utils'
33import { omit } from '@styled-system/props'
44import React , { FocusEventHandler , KeyboardEventHandler , MouseEventHandler , RefObject , useRef , useState } from 'react'
55import Box from './Box'
6- import { useProvidedRefOrCreate } from './hooks'
7- import { useCombinedRefs } from './hooks/useCombinedRefs'
6+ import { useRefObjectAsForwardedRef } from './hooks/useRefObjectAsForwardedRef'
87import { useFocusZone } from './hooks/useFocusZone'
98import Text from './Text'
109import { TextInputProps } from './TextInput'
@@ -93,12 +92,11 @@ function TextInputWithTokensInnerComponent<TokenComponentType extends AnyReactCo
9392 visibleTokenCount,
9493 ...rest
9594 } : TextInputWithTokensProps < TokenComponentType > ,
96- externalRef : React . ForwardedRef < HTMLInputElement >
95+ forwardedRef : React . ForwardedRef < HTMLInputElement >
9796) {
9897 const { onBlur, onFocus, onKeyDown, ...inputPropsRest } = omit ( rest )
99- const ref = useProvidedRefOrCreate < HTMLInputElement > ( externalRef as React . RefObject < HTMLInputElement > )
100- const localInputRef = useRef < HTMLInputElement > ( null )
101- const combinedInputRef = useCombinedRefs ( localInputRef , ref )
98+ const ref = useRef < HTMLInputElement > ( null )
99+ useRefObjectAsForwardedRef ( forwardedRef , ref )
102100 const [ selectedTokenIndex , setSelectedTokenIndex ] = useState < number | undefined > ( )
103101 const [ tokensAreTruncated , setTokensAreTruncated ] = useState < boolean > ( Boolean ( visibleTokenCount ) )
104102 const { containerRef} = useFocusZone (
@@ -124,7 +122,7 @@ function TextInputWithTokensInnerComponent<TokenComponentType extends AnyReactCo
124122 }
125123
126124 if ( nextIndex > tokens . length || nextIndex < 1 ) {
127- return combinedInputRef . current || undefined
125+ return ref . current || undefined
128126 }
129127
130128 return containerRef . current ?. children [ nextIndex ] as HTMLElement
@@ -230,7 +228,7 @@ function TextInputWithTokensInnerComponent<TokenComponentType extends AnyReactCo
230228 }
231229
232230 const focusInput : MouseEventHandler = ( ) => {
233- combinedInputRef . current ?. focus ( )
231+ ref . current ?. focus ( )
234232 }
235233
236234 const preventTokenClickPropagation : MouseEventHandler = event => {
@@ -323,7 +321,7 @@ function TextInputWithTokensInnerComponent<TokenComponentType extends AnyReactCo
323321 } }
324322 >
325323 < UnstyledTextInput
326- ref = { combinedInputRef }
324+ ref = { ref }
327325 disabled = { disabled }
328326 onFocus = { handleInputFocus }
329327 onBlur = { handleInputBlur }
0 commit comments