Hammerspoon / hammerspoon

Staggeringly powerful macOS desktop automation with Lua
http://www.hammerspoon.org
MIT License
12.17k stars 587 forks source link

Webview <input type="file"/> does not trigger file selector #1729

Open debbbbie opened 6 years ago

debbbbie commented 6 years ago

@josephholsten @jfchevrette @freewizard @mgee @knu

Can you fix this? I think it's a very important feature.

cmsj commented 6 years ago

Did this used to work? Or has it never worked?

latenitefilms commented 6 years ago

I've never been able to get this to work. I believe it's a sandboxing issue?

My workaround has been to use JavaScript callbacks to trigger a Lua-based file prompt.

debbbbie commented 6 years ago

@latenitefilms How did you do that? Can you share your code with me? Thanks!

debbbbie commented 6 years ago

@cmsj It should has never worked.

latenitefilms commented 6 years ago

You can see our code here:

https://github.com/CommandPost/CommandPost/tree/develop/src/plugins/core/preferences/panels/streamdeck

Hopefully it makes SOME sense. Any questions let me know!

cmsj commented 6 years ago

It does look to me like WKWebView supports file input tags, but I'm not currently familiar enough with hs.webview to investigate much further.

@debbbbie what would you expect to happen when the user has selected some files? Some kind of Lua callback?

latenitefilms commented 6 years ago

@cmsj - Does this mean anything to you?

https://stackoverflow.com/a/40840807

debbbbie commented 6 years ago

@cmsj when the user has selected some files, I think:

  1. the file input tag should get this file, like a true webview. Then the form can submit, and so on.
  2. hammerspoon can get this file info.

But, as latenitefilms has provided an idea, we can use lua to prompt a chooseFileOrFolder dialog, this can be used now.