Skip to content

Commit

Permalink
fix(FilePickerBuilder): Fix paths returned in Promise by pick metho…
Browse files Browse the repository at this point in the history
…d and reject if nothing is picked

Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
  • Loading branch information
susnux committed Aug 27, 2023
1 parent 69ad471 commit d31a45f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
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

0 comments on commit d31a45f

Please sign in to comment.