Skip to content

Commit

Permalink
fix(FilePicker): Stop default close event in case of button press
Browse files Browse the repository at this point in the history
Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>

[skip ci]
  • Loading branch information
susnux authored and backportbot[bot] committed Apr 12, 2024
1 parent 543efa7 commit 2927037
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions lib/components/FilePicker/FilePicker.vue
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,8 @@ const emit = defineEmits<{
(e: 'close', v?: Node[]): void
}>()
const isOpen = ref(true)
/**
* Whether we are on a public endpoint (e.g. public share)
*/
Expand Down Expand Up @@ -153,6 +155,20 @@ const dialogButtons = computed(() => {
} as IFilePickerButton))
})
/**
* Flag that is set when a button was clicked to prevent the default close event to be emitted
* This is needed as `handleButtonClick` is async and thus might execute after NcDialog already closed
*/
let isHandlingCallback = false
const handleButtonClick = async (callback: IFilePickerButton['callback']) => {
const nodes = selectedFiles.value.length === 0 && props.allowPickDirectory ? [await getFile(currentPath.value)] : selectedFiles.value as Node[]
callback(nodes)
emit('close', nodes)
// Unlock close
isHandlingCallback = false
}
/**
* Name of the currently active view
*/
Expand Down

0 comments on commit 2927037

Please sign in to comment.