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

fix(FilePickerBuilder): Fix paths returned in Promise by pick method #963

Merged
merged 1 commit into from
Aug 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions lib/filepicker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,10 @@ export class FilePicker<IsMultiSelect extends boolean> {
mimetypeFilter: this.mimeTypeFilter,
multiselect: this.multiSelect,
filterFn: this.filter,
}, (...nodes: unknown[]) => {
if (!nodes) {
reject(new Error('Nothing selected'))
}, (...rest: unknown[]) => {
const [nodes] = rest as [nodes: Node[]]
if (!Array.isArray(nodes) || nodes.length === 0) {
reject(new Error('FilePicker: No nodes selected'))
} else {
if (this.multiSelect) {
resolve((nodes as Node[]).map((node) => node.path) as (IsMultiSelect extends true ? string[] : string))
Expand Down
4 changes: 2 additions & 2 deletions lib/utils/dialogs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
*/
import type { AsyncComponent, Component } from 'vue'

import Vue from 'vue'
import Vue, { toRaw } from 'vue'

/**
* Helper to spawn a Vue dialog without having to mount it from a component
Expand All @@ -44,7 +44,7 @@ export const spawnDialog = (dialog: Component | AsyncComponent, props: any, onCl
props,
on: {
close: (...rest: unknown[]) => {
onClose(rest)
onClose(...rest.map(v => toRaw(v)))
vue.$destroy()
},
},
Expand Down