File tree Expand file tree Collapse file tree 2 files changed +8
-10
lines changed Expand file tree Collapse file tree 2 files changed +8
-10
lines changed Original file line number Diff line number Diff line change @@ -11,7 +11,7 @@ export default {
1111} as Meta ;
1212
1313export const CustomFinder = ( ) => {
14- const [ search , setSearch ] = useState ( '' ) ;
14+ const [ search , setSearch ] = useState ( 'pizza ' ) ;
1515 const tree = useRef < TreeRef > ( null ) ;
1616
1717 const dataProvider = useMemo (
@@ -47,12 +47,11 @@ export const CustomFinder = () => {
4747 if ( search ) {
4848 findItemPath ( search ) . then ( path => {
4949 if ( path ) {
50- tree . current
51- ?. expandSubsequently ( path . slice ( 0 , path . length - 1 ) )
52- . then ( ( ) => {
53- tree . current ?. selectItems ( [ path [ path . length - 1 ] ] ) ;
54- tree . current ?. focusItem ( path [ path . length - 1 ] ) ;
55- } ) ;
50+ // wait for full path including leaf, to make sure it loaded in
51+ tree . current ?. expandSubsequently ( path ) . then ( ( ) => {
52+ tree . current ?. selectItems ( [ path [ path . length - 1 ] ] ) ;
53+ tree . current ?. focusItem ( path [ path . length - 1 ] ) ;
54+ } ) ;
5655 }
5756 } ) ;
5857 }
Original file line number Diff line number Diff line change @@ -157,9 +157,8 @@ function App() {
157157 if (search) {
158158 findItemPath (search).then (path => {
159159 if (path) {
160- tree .current
161- .expandSubsequently (path .slice (0 , path .length - 1 ))
162- .then (() => {
160+ // wait for full path including leaf, to make sure it loaded in
161+ tree .current ? .expandSubsequently (path).then (() => {
163162 tree .current .selectItems ([path[path .length - 1 ]]);
164163 tree .current .focusItem (path[path .length - 1 ]);
165164 });
You can’t perform that action at this time.
0 commit comments