@@ -45,7 +45,7 @@ export const CopyAddressItemList = ({
4545 containerStyle,
4646 copyItemAddressHoverColor,
4747} : CopyAddressItemListProps ) => {
48- const [ focusedIndex , setFocusedIndex ] = useState < number | null > ( null ) ;
48+ const [ focusedIndex , setFocusedIndex ] = useState < number | null > ( 0 ) ;
4949 const [ hoveredIndex , setHoveredIndex ] = useState < number | null > ( null ) ;
5050 const itemContainerRefs = useRef < ( HTMLDivElement | null ) [ ] > ( [ ] ) ;
5151 const itemHandlesRef = useRef < ( CopyAddressItemHandle | null ) [ ] > ( [ ] ) ;
@@ -78,12 +78,15 @@ export const CopyAddressItemList = ({
7878 [ sortedAddresses ]
7979 ) ;
8080
81+ const previousTrimSearchRef = useRef ( "" ) ;
82+
8183 // keyDown addEventListener를 마운트 될때 한번 등록하기 위해서
8284 // 관련 상태를 ref로 관리함
8385 const focusedIndexRef = useRef < number | null > ( focusedIndex ) ;
8486 const maxIndexRef = useRef < number > ( 0 ) ;
8587 const hoveredIndexRef = useRef < number | null > ( hoveredIndex ) ;
8688 const blockInteractionRef = useRef < boolean > ( blockInteraction ) ;
89+
8790 useEffect ( ( ) => {
8891 focusedIndexRef . current = focusedIndex ;
8992 maxIndexRef . current = flattenedAddresses . length - 1 ;
@@ -116,9 +119,13 @@ export const CopyAddressItemList = ({
116119 setFocusOrigin ( "search" ) ;
117120 setFocusedIndex ( 0 ) ;
118121 } else {
119- setFocusedIndex ( null ) ;
122+ if ( previousTrimSearchRef . current . length > 0 ) {
123+ setFocusedIndex ( null ) ;
124+ }
120125 }
121126
127+ previousTrimSearchRef . current = search . trim ( ) ;
128+
122129 setHoveredIndex ( null ) ;
123130 } , [ search , flattenedAddresses . length ] ) ;
124131
@@ -295,7 +302,7 @@ export const EnterTag = () => {
295302 : ColorPalette [ "gray-200" ] ,
296303 } }
297304 >
298- Ent
305+ Enter
299306 </ div >
300307 < _EnterIcon
301308 color = {
0 commit comments