fix(FileUpload): fix broken choose button in basic mode, fixes #6257, #5748

This fix removes the initial code for a transformation to an upload button
since the code is incomplete. It also removes the bug that you cannot
perform additional file selections.
pull/6259/head
Michael Meier 2024-08-19 18:49:35 +02:00
parent 6284b031eb
commit 0c5bf84aa4
No known key found for this signature in database
GPG Key ID: D6DB4798F2AC7B5A
1 changed files with 7 additions and 6 deletions

View File

@ -58,10 +58,7 @@
<Message v-for="msg of messages" :key="msg" severity="error" @close="onMessageClose" :unstyled="unstyled" :pt="ptm('pcMessages')">{{ msg }}</Message>
<Button :label="chooseButtonLabel" :class="chooseButtonClass" :style="style" :disabled="disabled" :unstyled="unstyled" @mouseup="onBasicUploaderClick" @keydown.enter="choose" @focus="onFocus" @blur="onBlur" v-bind="ptm('pcButton')">
<template #icon="iconProps">
<slot v-if="!hasFiles || auto" name="uploadicon">
<component :is="uploadIcon ? 'span' : 'UploadIcon'" :class="[iconProps.class, uploadIcon]" aria-hidden="true" v-bind="ptm('pcButton')['icon']" />
</slot>
<slot v-else name="chooseicon">
<slot name="chooseicon">
<component :is="chooseIcon ? 'span' : 'PlusIcon'" :class="[iconProps.class, chooseIcon]" aria-hidden="true" v-bind="ptm('pcButton')['icon']" />
</slot>
</template>
@ -71,7 +68,7 @@
{{ basicFileChosenLabel }}
</span>
</slot>
<input v-if="!hasFiles" ref="fileInput" type="file" :accept="accept" :disabled="disabled" :multiple="multiple" @change="onFileSelect" @focus="onFocus" @blur="onBlur" v-bind="ptm('input')" />
<input ref="fileInput" type="file" :accept="accept" :disabled="disabled" :multiple="multiple" @change="onFileSelect" @focus="onFocus" @blur="onBlur" v-bind="ptm('input')" />
</div>
</template>
@ -108,7 +105,7 @@ export default {
if (this.hasFiles) this.uploader();
},
onBasicUploaderClick(event) {
if (event.button === 0 && !this.hasFiles) this.$refs.fileInput.click();
if (event.button === 0) this.$refs.fileInput.click();
},
onFileSelect(event) {
if (event.type !== 'drop' && this.isIE11() && this.duplicateIEEvent) {
@ -117,6 +114,10 @@ export default {
return;
}
if (this.isBasic && this.hasFiles) {
this.files = [];
}
this.messages = [];
this.files = this.files || [];
let files = event.dataTransfer ? event.dataTransfer.files : event.target.files;