File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -35,7 +35,10 @@ function SearchMultipleSelectionPicker<T extends string | string[]>({
3535
3636 const [ initialSelectedIDs ] = useState ( ( ) => new Set ( ( initiallySelectedItems ?? [ ] ) . map ( ( item ) => item . value . toString ( ) ) ) ) ;
3737 const [ selectedItemIDs , setSelectedItemIDs ] = useState ( ( ) => initialSelectedIDs ) ;
38- const [ initiallyFocusedKeyComputed ] = useState ( ( ) => {
38+ // Clear after mount to prevent FlashList from auto-scrolling when data changes
39+ // cause the key to transition from "not found" to "found" (e.g., clearing a search).
40+ // Deferred by one frame so FlashList processes the initial scroll first.
41+ const [ initiallyFocusedKey , setInitiallyFocusedKey ] = useState ( ( ) => {
3942 let minItem : SearchMultipleSelectionPickerItem < T > | undefined ;
4043 for ( const item of items ) {
4144 if ( initialSelectedIDs . has ( item . value . toString ( ) ) ) {
@@ -46,11 +49,6 @@ function SearchMultipleSelectionPicker<T extends string | string[]>({
4649 }
4750 return minItem ?. name ;
4851 } ) ;
49-
50- // Clear after mount to prevent FlashList from auto-scrolling when data changes
51- // cause the key to transition from "not found" to "found" (e.g., clearing a search).
52- // Deferred by one frame so FlashList processes the initial scroll first.
53- const [ initiallyFocusedKey , setInitiallyFocusedKey ] = useState ( initiallyFocusedKeyComputed ) ;
5452 useEffect ( ( ) => {
5553 const id = requestAnimationFrame ( ( ) => {
5654 setInitiallyFocusedKey ( undefined ) ;
You can’t perform that action at this time.
0 commit comments