Skip to content

Commit

Permalink
fix(FileUpload): fix broken choose button in basic mode, fixes primef…
Browse files Browse the repository at this point in the history
…aces#6257, primefaces#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.
  • Loading branch information
kitmeier committed Aug 19, 2024
1 parent 6284b03 commit 0c5bf84
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 0c5bf84

Please sign in to comment.