rfd icon indicating copy to clipboard operation
rfd copied to clipboard

open os file picker directly on pickfile in wasm

Open JustFrederik opened this issue 2 years ago • 2 comments
trafficstars

When using pickfile it creates html code like this:

<div id="rfd-card"><input id="rfd-input" type="file" accept=""><button id="rfd-button">Ok</button></div>

Coud you add an option like set_overlay to AsyncFileDialog which lets you skip this rfd-card and open the os file picker directly? The easiest solution would probably be to add an eventlistener to input instead of button.set_onclick(Some(closure.as_ref().unchecked_ref())); in wasm.rs:94 and add the visibility of the body.

JustFrederik avatar Aug 01 '23 21:08 JustFrederik

https://github.com/JustFrederik/rfd

JustFrederik avatar Aug 01 '23 21:08 JustFrederik

It seems like the FileSystem APIs are available on all browsers now: https://developer.mozilla.org/en-US/docs/Web/API/FileSystemHandle

But the APIs required to create handles to files on the user's machine (showDirectoryPicker, showOpenDirectoryPicker, showSaveFilePicker) are Chromium-only. That being said, they are significantly simpler than the existing approach, and they do provide a much better experience, requiring no extra dialog to make them work. Maybe rfd could use those APIs if they are available, and fallback to the current implementation if not?

jprochazk avatar Aug 13 '24 15:08 jprochazk