fix(file-upload): [file-upload] Fix the hidden feature bug in props.isHidden (#1617)

This commit is contained in:
chenxi-20 2024-05-10 14:30:04 +08:00 committed by GitHub
parent d4faaacdad
commit e339a704a8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 30 additions and 28 deletions

View File

@ -87,37 +87,39 @@ export default defineComponent({
const operateSlot = this.slots.operate && this.slots.operate()
const tipSlot = this.slots.tip && this.slots.tip()
const uploadStyle = isHidden && fileList.length >= limit ? { display: 'none' } : null
const hidden = isHidden && fileList.length >= limit
return (
<div class={['tiny-upload', `tiny-upload--${listType}`, disabled ? 'is-disabled' : '']} style={uploadStyle}>
<div
class="tiny-upload-btn"
onClick={($event) => handleClick($event, type)}
onPaste={handlePaste}
onKeydown={handleKeydown}
tabindex="0">
{drag ? (
<UploadDragger disabled={disabled} onFile={uploadFiles}>
{defaultSlot}
</UploadDragger>
) : (
defaultSlot
)}
!hidden && (
<div class={['tiny-upload', `tiny-upload--${listType}`, disabled ? 'is-disabled' : '']}>
<div
class="tiny-upload-btn"
onClick={($event) => handleClick($event, type)}
onPaste={handlePaste}
onKeydown={handleKeydown}
tabindex="0">
{drag ? (
<UploadDragger disabled={disabled} onFile={uploadFiles}>
{defaultSlot}
</UploadDragger>
) : (
defaultSlot
)}
</div>
{operateSlot}
{tipSlot}
<input
class="tiny-upload__input"
type="file"
webkitdirectory={isFolder}
ref="input"
name={name}
onChange={handleChange}
multiple={isFolder ? true : multiple}
accept={accept}
/>
</div>
{operateSlot}
{tipSlot}
<input
class="tiny-upload__input"
type="file"
webkitdirectory={isFolder}
ref="input"
name={name}
onChange={handleChange}
multiple={isFolder ? true : multiple}
accept={accept}
/>
</div>
)
)
}
})