Skip to content

Commit 86e69d3

Browse files
committed
fix: upload limit error, close #5385
1 parent ecab7f6 commit 86e69d3

File tree

2 files changed

+16
-10
lines changed

2 files changed

+16
-10
lines changed

components/upload/Upload.tsx

+5-4
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ export default defineComponent({
296296
defaultLocale.Upload,
297297
computed(() => props.locale),
298298
);
299-
const renderUploadList = (button?: VueNode, buttonVisible?: boolean) => {
299+
const renderUploadList = (button?: () => VueNode, buttonVisible?: boolean) => {
300300
const {
301301
removeIcon,
302302
previewIcon,
@@ -333,10 +333,11 @@ export default defineComponent({
333333
progress={progress}
334334
itemRender={itemRender}
335335
appendActionVisible={buttonVisible}
336-
v-slots={{ ...slots, appendAction: () => button }}
336+
appendAction={button}
337+
v-slots={{ ...slots }}
337338
/>
338339
) : (
339-
button
340+
button?.()
340341
);
341342
};
342343
return () => {
@@ -414,7 +415,7 @@ export default defineComponent({
414415
if (listType === 'picture-card') {
415416
return (
416417
<span class={classNames(`${prefixCls.value}-picture-card-wrapper`, attrs.class)}>
417-
{renderUploadList(renderUploadButton(), !!(children && children.length))}
418+
{renderUploadList(renderUploadButton, !!(children && children.length))}
418419
</span>
419420
);
420421
}

components/upload/UploadList/index.tsx

+11-6
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,16 @@ import Button from '../../button';
1010
import ListItem from './ListItem';
1111
import type { HTMLAttributes } from 'vue';
1212
import { computed, defineComponent, getCurrentInstance, onMounted, ref, watchEffect } from 'vue';
13-
import { initDefaultProps, isValidElement } from '../../_util/props-util';
13+
import { filterEmpty, initDefaultProps, isValidElement } from '../../_util/props-util';
1414
import type { VueNode } from '../../_util/type';
1515
import useConfigInject from '../../_util/hooks/useConfigInject';
1616
import { getTransitionGroupProps, TransitionGroup } from '../../_util/transition';
1717
import collapseMotion from '../../_util/collapseMotion';
1818

1919
const HackSlot = (_, { slots }) => {
20-
return slots.default?.()[0];
20+
return filterEmpty(slots.default?.())[0];
2121
};
22+
2223
export default defineComponent({
2324
name: 'AUploadList',
2425
props: initDefaultProps(uploadListProps(), {
@@ -166,11 +167,11 @@ export default defineComponent({
166167
previewIcon,
167168
downloadIcon,
168169
progress,
169-
appendAction = slots.appendAction,
170+
appendAction,
170171
itemRender,
171172
appendActionVisible,
172173
} = props;
173-
const appendActionDom = appendAction?.()[0];
174+
const appendActionDom = appendAction?.();
174175
return (
175176
<TransitionGroup {...transitionGroupProps.value} tag="div">
176177
{items.map(file => {
@@ -203,8 +204,12 @@ export default defineComponent({
203204
/>
204205
);
205206
})}
206-
{appendActionVisible && isValidElement(appendActionDom) ? (
207-
<HackSlot key="__ant_upload_appendAction">{appendActionDom}</HackSlot>
207+
{appendAction ? (
208+
<HackSlot
209+
key="__ant_upload_appendAction"
210+
v-show={!!appendActionVisible}
211+
v-slots={{ default: () => appendActionDom }}
212+
></HackSlot>
208213
) : null}
209214
</TransitionGroup>
210215
);

0 commit comments

Comments
 (0)