Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

go-to doesn't work with async function #27

Open
gillez opened this issue Jul 31, 2019 · 1 comment
Open

go-to doesn't work with async function #27

gillez opened this issue Jul 31, 2019 · 1 comment

Comments

@gillez
Copy link

gillez commented Jul 31, 2019

When initialising finder using an async function rather than static array, the "go-to" event does not work.

The following error is seen in the console:

TypeError: n.find is not a function at Function.finder.selectPath (vendor/finder.min.js)

This is because finder.selectPath is passed the original "data" and expects this to be an array, calling data.find to get the path. However, in this case data is a function and the above error occurs.

I know that go-to may not be possible to find a path which hasn't been retrieved by the async function (and defaultPath wouldn't work at all for the same reason). However, in my case I am emitting go-to to navigate to a path that I know is in the data that already exists in the tree.

What I really want to do is automatically select the top-level child if there is only a single top-level child after building the tree in the async function. Is there a way to do this?

Thanks,
Giles

@mynameistechno
Copy link
Owner

Sorry for the delay in response. Have you solved this?

Potentially the library could be tweaked to work in async mode if the data has loaded, but perhaps the most flexible approach would be to listen to the right event and then select the item if there is only one (e.g. column-created maybe? I have to look at the code to see if we have an appropriate event).

I'm not sure if the above is possible with the lib as-is, but in theory doesn't sound too bad to add the functionality.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants