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

Fix problem with expandSubsequently resolving before expanding all items #403

Merged

Conversation

kamilkazmierczakMtab
Copy link
Contributor

Issue solved:
expandSubsequently does not wait to expand all items provided in argument. In rare cases it leads to errors.

Additional info:

  1. Tests are failing for some reason but they are failing even without my changes (locally)
  2. This is fixing a lot of problems but not all - e.g. in your story (https://rct.lukasbach.com/storybook/?path=/story/core-finding-items--custom-finder) after typing pizza you will get error Cannot read properties of undefined (reading 'index') this is similar to error that I was getting but my fix is not addressing that because Europe item is not expanded before this function resolves - this is because onExpandItem is not returning promise so I can't wait for it.

@lukasbach

@ajhous44
Copy link

ajhous44 commented Aug 1, 2024

+1

@lukasbach
Copy link
Owner

Thank you for the contribution! I will have another look at why the other error seems to come up.

@lukasbach lukasbach merged commit b4742d4 into lukasbach:main Aug 4, 2024
6 checks passed
@lukasbach
Copy link
Owner

In regards to the error in your second point, the logged error here seems to come from the call to focus the "Pizza" item in the story, but exandSubsequently was just called on all items above that, with expandSubsequently(path.slice(0, path.length - 1)) it just expanded "root", "Meals" and "Europe", but then called the focus method on "Pizza" without waiting for it to be loaded in first.

As a dirty fix, it actually works fine when the target leaf is also included in the expandSubsequently call with expandSubsequently(path), this will make the call wait until the Pizza leaf is loaded in as well. So something like this will fix it: 58e3ed9

This does have the disadvantage that the searched item will also be expanded if it is a folder, if this is not desired, some custom waiting would need to be implemented to make sure the item is loaded in before proceeding with doing things with it.

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

Successfully merging this pull request may close these issues.

3 participants