Skip to content

Commit

Permalink
Merge pull request #6259 from m-meier/fix-6257
Browse files Browse the repository at this point in the history
fix(FileUpload): fix broken choose button in basic mode, fixes #6257,…
  • Loading branch information
tugcekucukoglu authored Aug 21, 2024
2 parents f3e1fdc + 0c5bf84 commit d30738b
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions packages/primevue/src/fileupload/FileUpload.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand All @@ -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>

Expand Down Expand Up @@ -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) {
Expand All @@ -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;
Expand Down

0 comments on commit d30738b

Please sign in to comment.