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

macOS: Missing UI delegate for WebView (no alerts, <input type="file"> dialog) #22

Open
denisw opened this issue Oct 18, 2022 · 2 comments
Labels
bug Something isn't working

Comments

@denisw
Copy link

denisw commented Oct 18, 2022

Describe the bug

WebKit's WKWebView needs an implementation of WKUIDelegate for some interactions that require native UI bits, such as:

  • JS alerts and prompts (alert(), confirm(), prompt())
  • File dialogs, e.g. when clicking on an <input type="file">

Neutralino does not provide such a delegate (see webview.h). Accordingly, the above browser features do not work on macOS (nothing happens).

To reproduce

  1. Create a new Neutralino project.
  2. Add <input type="file"> to the HTML.
  3. Add alert('foo') call to the JavaScript code.
  4. Run the app with neu run.

Expected behavior

  • I can see a dialog saying "foo" when I start the app.
  • Clicking on the file input opens a file dialog.

Actual behavior

  • No dialog is shown.
  • Clicking on the file input does nothing (but dragging a file from Finder to the file input works).

Specifications

  • OS: macOS 12.6 arm64
  • Neutralinojs version: v4.8.0
  • Neutralinojs client library version: v3.7.0
  • Neutralinojs CLI version: v9.3.1

Additional context

Follow-up of neutralinojs/neutralinojs#1005.

@ghost
Copy link

ghost commented Nov 13, 2022

File dialogs, e.g. when clicking on an <input type="file">

I only tested on macOS and assumed this was by design.
I personally abstracted this away in our app like this:

      Neutralino.os.showOpenDialog('Open a file', {
        multiSelections: false
      }).then((entries) => {
        const path = entries[0];
        Neutralino.filesystem.readBinaryFile(path).then((data) => {
          const dataArray = new Uint8Array(data);
          callback(dataArray, path);
        });
      })
      return;

I added similar code for downloading / saving a file.

@denisw
Copy link
Author

denisw commented Nov 14, 2022

I don’t think it is by design because these features work out of the box on both Windows and Linux. I assume it is just an oversight in the macOS implementation, which requires manual wiring code for these things to work (the mentioned UI delegate) while the other platforms’ webview libraries don’t.

@shalithasuranga shalithasuranga transferred this issue from neutralinojs/neutralinojs Nov 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant