PolyMeilex / rfd

Rusty File Dialog
MIT License
564 stars 64 forks source link

#128 fix #129

Open JustFrederik opened 1 year ago

JustFrederik commented 1 year ago

128 fix

PolyMeilex commented 1 year ago

That's a cool idea, but I'm pretty sure the supplied code does not work, the future will resolve immediately after click event and return None. And as far as I know there is no way to do this in HTML5 (would love to be proven wrong tho)

This could be possible with Chrome specific File System Access API, but that's a more complex to implement, and I'm not sure if it's worth implementing if it can not replace HTML code any time soon if ever (file system access is a controversial spec).

JustFrederik commented 1 year ago

@PolyMeilex sorry i havent checked the ouput and you are right the event triggers as soon as it is pressed, but i dont know why. i tried out the events with plain html and it works like it is supposed to. <input type="file" onclick="console.log('clicked')" onchange="console.log('change')" multiple>. The onclick event triggers as soon as it is pressed and the onchange request triggers when the window is closed. Im not sure why it isnt working

JustFrederik commented 1 year ago

@PolyMeilex i moved the eventlistener after the html is attached so the event wont be triggered immediately. Now it will only be triggered when a file is selected. I will look into it if there is an event that would be better suited than onchange.

PolyMeilex commented 1 year ago

Even if you fix that, what's your plan for handling dialog cancelation? It does not trigger onChange as far as I remember

JustFrederik commented 1 year ago

@PolyMeilex chrome and safari focus the last focued element on close. Im looking into it how it could be deteted in firefox. alternativly it could be an option that it auto closes when a file is submitted and auto opens, but still display the popup as a fallback in case it is cancled.

frewsxcv commented 10 months ago

This could be possible with Chrome specific File System Access API, but that's a more complex to implement, and I'm not sure if it's worth implementing if it can not replace HTML code any time soon if ever (file system access is a controversial spec).

This doesn't appear to be Chrome specific. Can you share why it's controversial?