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 19944b7 commit ff26ce1
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions packages/primevue/src/fileupload/FileUpload.vue
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,7 @@
:pt="ptm('pcChooseButton')"
>
<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 @@ -83,7 +80,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 @@ -120,9 +117,14 @@ 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 (this.isBasic && this.hasFiles) {
this.files = [];
this.messages = null;
}
if (event.type !== 'drop' && this.isIE11() && this.duplicateIEEvent) {
this.duplicateIEEvent = false;
Expand Down

0 comments on commit ff26ce1

Please sign in to comment.