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

[bug] FileDialogBuilder::set_parent not working on macOS #3312

Closed
probablykasper opened this issue Jan 31, 2022 · 3 comments
Closed

[bug] FileDialogBuilder::set_parent not working on macOS #3312

probablykasper opened this issue Jan 31, 2022 · 3 comments

Comments

@probablykasper
Copy link
Member

Describe the bug

set_parent does not seem to work on macOS. When it's used, the file dialog should be attached to the window, like in the rfd winit example:
Screenshot 2022-01-31 at 1 14 59 AM

Reproduction

#[tauri::command]
pub async fn open(win: tauri::Window) -> Result<(), String> {
  let mut d =  tauri::api::dialog::FileDialogBuilder::new().set_parent(&win);
  let (sender, receiver) = std::sync::mpsc::channel();
  d.pick_file(move |p| {
    sender.send(p).unwrap();
  });
  let file_path = match receiver.recv().unwrap_or_default() {
    Some(p) => p,
    None => return Ok(()),
  };
  println!("file_path {:?}", file_path);
  Ok(())
}

Expected behavior

No response

Platform and versions

Operating System - Mac OS, version 10.15.7 X64

Node.js environment
  Node.js - 16.13.1
  @tauri-apps/cli - 1.0.0-beta.10
  @tauri-apps/api - 1.0.0-beta.8

Global packages
  npm - 8.1.2
  yarn - 1.22.17

Rust environment
  rustc - 1.58.0
  cargo - 1.58.0

App directory structure
/node_modules
/public
/src-tauri
/build
/.git
/src

App
  tauri.rs - 1.0.0-beta.8
  build-type - bundle
  CSP - default-src blob: data: filesystem: ws: wss: http: https: tauri: 'unsafe-eval' 'unsafe-inline' 'self' img-src: 'self'
  distDir - ../build
  devPath - http://localhost:5000
  framework - Svelte

Stack trace

No response

Additional context

No response

@probablykasper
Copy link
Member Author

Seems like it works in rfd for AsyncFileDialog, but not for FileDialog which Tauri uses

@probablykasper
Copy link
Member Author

Opened PolyMeilex/rfd#53

Is there any reason why Tauri isn't using AsyncFileDialog?

@m11m
Copy link

m11m commented Feb 27, 2022

It kind of looks like you'd need to use AsyncFileDialog to get "sheet" behavior...

or maybe rfd would have to handle the async stuff in some sync wrapper?

The AsyncFileDialog uses https://developer.apple.com/documentation/appkit/nssavepanel/1535870-beginsheetmodalforwindow/ which seems async to me (takes completion handler parameter) ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants