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] dialog.open + multiple + directory can only return one directory #4091

Closed
martpie opened this issue May 9, 2022 · 4 comments
Closed

Comments

@martpie
Copy link

martpie commented May 9, 2022

Describe the bug

const selectedFolders = await dialog.open({
    directory: true,
    multiple: true,
});

only allows you to select a single directory.

Screen.Recording.2022-05-09.at.19.11.20.mov

Reproduction

  1. Create a tauri app with create react-app
  2. Enable dialog in tauri config
  3. Use the following code as component:
import React, { useCallback, useState } from 'react';
import * as dialog from '@tauri-apps/api/dialog';

const Root: React.FC = () => {
  const [folders, setFolders] = useState<string[]>([]);

  const onOpen = useCallback(async () => {
    const selectedFolders = await dialog.open({
      directory: true,
      multiple: true,
    });

    if (selectedFolders === null) {
      setFolders([]);
    } else if (typeof selectedFolders === 'string') {
      setFolders([selectedFolders]);
    } else {
      setFolders(selectedFolders);
    }
  }, []);

  return (
    <>
      <button onClick={onOpen}>Open folder</button>
      <br />
      {folders.join(',')}
    </>
  );
};

export default Root;
  1. Launch app, click on button, try to to open multiple directories

Expected behavior

It should allow the user to select multiple directories at once :]

Platform and versions

Environment
  › OS: Mac OS 12.3.1 X64
  › Node.js: 18.0.0
  › npm: 8.6.0
  › pnpm: Not installed!
  › yarn: 1.22.18
  › rustup: Not installed!
  › rustc: 1.59.0
  › cargo: 1.59.0
  › Rust toolchain:

Packages
  › @tauri-apps/cli [NPM]: 1.0.0-rc.10
  › @tauri-apps/api [NPM]: 1.0.0-rc.5
  › tauri [RUST]: 1.0.0-rc.9,
  › tauri-build [RUST]: 1.0.0-rc.8,
  › tao [RUST]: 0.8.4,
  › wry [RUST]: 0.16.0,

App
  › build-type: bundle
  › CSP: default-src 'none'; img-src 'self' data:; media-src 'self'; child-src 'self'; object-src 'self'; script-src 'self'; style-src 'self' 'unsafe-inline'; connect-src 'self' https://api.github.com; font-src 'self' data:
  › distDir: ../build
  › devPath: http://localhost:3000/
  › framework: React

App directory structure
  ├─ node_modules
  ├─ public
  ├─ src-tauri
  ├─ build
  ├─ .git
  └─ src


### Stack trace

_No response_

### Additional context

_No response_
@FabianLars
Copy link
Member

The dialog upstream crate doesn't support this.
But honestly, i've never seen a file picker that allows picking multiple directories (at least on Windows&Linux, never used macOS) 🤔

@martpie martpie changed the title [bug] [bug] dialog.open + multiple + directoriy can only return one directory May 9, 2022
@martpie
Copy link
Author

martpie commented May 9, 2022

I come from Electron, and their their dialog module supports it, but I will double check on Windows and Linux.

Opening a feature request upstream should probably be the best then, thanks for the pointer!

@martpie martpie closed this as completed May 9, 2022
@martpie martpie changed the title [bug] dialog.open + multiple + directoriy can only return one directory [bug] dialog.open + multiple + directory can only return one directory May 9, 2022
@martpie martpie reopened this Jun 15, 2022
@martpie
Copy link
Author

martpie commented Jun 15, 2022

@FabianLars rfd implemented it upstream (PolyMeilex/rfd@ac1217a), I'll keep this open until a new rfd release is released.

This should hopefully work out of the box without any change to Tauri!

betamos added a commit to betamos/tauri that referenced this issue Jun 15, 2022
@betamos
Copy link
Contributor

betamos commented Jun 15, 2022

Unfortunately it won't work out of the box -- the API is designed with fn names, not boolean params. I'm working on a PR.

betamos added a commit to betamos/tauri that referenced this issue Jun 15, 2022
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

3 participants