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

save callback on this, and await folder functions #242

Merged
merged 2 commits into from
Aug 28, 2024

Conversation

FoamyGuy
Copy link

@FoamyGuy FoamyGuy commented Aug 28, 2024

This chang fixes an issue that is occurring for me in the beta version of the editor. Both the deployed beta page, and the beta branch when running locally behave the same for me and they're currently having this Javascript error when I click the 'Select Host Folder' or 'Use Host Folder' buttons

index.js:94 Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'getFileClient')
    at HTMLButtonElement._selectHostFolder (index.js:94:3384)

I added some additional console logging and found that this.fileHelper was indeed undefined when it tried to be accessed by this callback.

I looked into the changes from main to beta and saw that these callbacks used to be wrapped in the anonymous async functions and awaited so I tried putting that back and it seems to resolve the issue.

I also store the callback so that it can later be passed to removeEventListener() This is very similar to what ended up being a fix for the duplicated serial output, I'll submit a separate PR for that fix though as its unrelated to this JS error I believe.

I tested this version locally and found that with it I am now able to select the host folder successfully and carry on using the editor.

Copy link
Collaborator

@makermelissa makermelissa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you

@makermelissa makermelissa merged commit eddc427 into circuitpython:beta Aug 28, 2024
1 check passed
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.

2 participants