Skip to content

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

@probablykasper

Description

@probablykasper

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions