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 {
11
11
} as Meta ;
12
12
13
13
export const CustomFinder = ( ) => {
14
- const [ search , setSearch ] = useState ( '' ) ;
14
+ const [ search , setSearch ] = useState ( 'pizza ' ) ;
15
15
const tree = useRef < TreeRef > ( null ) ;
16
16
17
17
const dataProvider = useMemo (
@@ -47,12 +47,11 @@ export const CustomFinder = () => {
47
47
if ( search ) {
48
48
findItemPath ( search ) . then ( path => {
49
49
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
+ } ) ;
56
55
}
57
56
} ) ;
58
57
}
Original file line number Diff line number Diff line change @@ -157,9 +157,8 @@ function App() {
157
157
if (search) {
158
158
findItemPath (search).then (path => {
159
159
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 (() => {
163
162
tree .current .selectItems ([path[path .length - 1 ]]);
164
163
tree .current .focusItem (path[path .length - 1 ]);
165
164
});
You can’t perform that action at this time.
0 commit comments