Skip to content

Commit 7cc1b2a

Browse files
authored
Merge pull request #48512 from nextcloud/fix/pick-folder-smart-picker
fix(files): Fix folders not being selectable in the smart picker
2 parents e333bc3 + 2d4fe1c commit 7cc1b2a

3 files changed

Lines changed: 14 additions & 15 deletions

File tree

apps/files/src/views/FileReferencePickerElement.vue

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ export default defineComponent({
3939
},
4040
filepickerOptions() {
4141
return {
42-
allowPickDirectory: false,
42+
allowPickDirectory: true,
4343
buttons: this.buttonFactory,
4444
container: `#${this.containerId}`,
4545
multiselect: false,
@@ -53,18 +53,17 @@ export default defineComponent({
5353
buttonFactory(selected: NcNode[]): IFilePickerButton[] {
5454
const buttons = [] as IFilePickerButton[]
5555
if (selected.length === 0) {
56-
buttons.push({
57-
label: t('files', 'Choose file'),
58-
type: 'tertiary' as never,
59-
callback: this.onClose,
60-
})
61-
} else {
62-
buttons.push({
63-
label: t('files', 'Choose {file}', { file: selected[0].basename }),
64-
type: 'primary',
65-
callback: this.onClose,
66-
})
56+
return []
57+
}
58+
const node = selected.at(0)
59+
if (node.path === '/') {
60+
return [] // Do not allow selecting the users root folder
6761
}
62+
buttons.push({
63+
label: t('files', 'Choose {file}', { file: node.displayname }),
64+
type: 'primary',
65+
callback: this.onClose,
66+
})
6867
return buttons
6968
},
7069

0 commit comments

Comments
 (0)