GoogleChromeLabs / browser-fs-access

File System Access API with legacy fallback in the browser
https://googlechromelabs.github.io/browser-fs-access/demo/
Apache License 2.0
1.37k stars 82 forks source link

Reference to undefined 'reject' variable in legacy fileSave method #106

Closed tmcw closed 2 years ago

tmcw commented 2 years ago

https://github.com/GoogleChromeLabs/browser-fs-access/blob/b3be8c6bd93d7be3388aed3ca77da258283494ba/src/legacy/file-save.mjs#L38

There's no reject variable in scope here. It looks like this bug has existed since the code was introduced:

https://github.com/GoogleChromeLabs/browser-fs-access/commit/8ed86033972796fc1531de91d13b86bc632571ea#diff-0a1bdb6eb4ee8c5dd800ceba3ea9beda6618f51150ef0152f552454c6cbfd92bR31

tomayac commented 2 years ago

Excalidraw uses this here. @dwelle can verify.

dwelle commented 2 years ago

Yes, the file-save legacy handling I wrote incorrectly. I'll make a fix in the coming days.

tomayac commented 2 years ago

Thanks, @dwelle! By the way, I noticed that the current Excalidraw workaround doesn't trigger in realtime for Firefox when I played with it again now. It's similarly ignored as was my earlier attempt based on similar ideas (https://github.com/GoogleChromeLabs/browser-fs-access/commit/9340b5810e4a311e3715a63121f765eecf6f829b and even earlier). It seems to trigger upon saving: open a file dialog, cancel it, then save, and only then you can see the "file open was canceled" log message trigger.

dwelle commented 2 years ago

Thanks, @dwelle! By the way, I noticed that the current Excalidraw workaround doesn't trigger in realtime for Firefox when I played with it again now. It's similarly ignored as was my earlier attempt based on similar ideas (9340b58 and even earlier). It seems to trigger upon saving: open a file dialog, cancel it, then save, and only then you can see the "file open was canceled" log message trigger.

Mhm, when did it regress, because I'm sure it worked around the time I was writing it 😭

dwelle commented 2 years ago

Wait, nvm, it still works for me. I've had warnings disabled in FF. Don't ever recall turning it off, can you check if that's the case for you as well?

image

tomayac commented 2 years ago

It works somewhat, but I don't get the logic by which it works:

https://user-images.githubusercontent.com/145676/165718054-165f4f51-31ae-4b99-acee-052b2e7c9e3b.mp4

dwelle commented 2 years ago

Ok, I was checking on Windows. I can repro the same issue on MacOS as you. Will take a look later.