fix(list-box): update conditional virtual loader reservations

This commit is contained in:
maoyingjie
2026-10-29 17:15:30 +08:00
parent 5a00e25a25
commit 6d9e3f31cf
2 changed files with 31 additions and 1 deletions
@@ -74,6 +74,7 @@ defineSlots<{
loader?: () => unknown;
}>();
const slots = useSlots();
const hasLoader = ref(Boolean(slots.loader));
const attrs = useAttrs();
const instance = getCurrentInstance()!;
const modelPresence = () =>
@@ -87,6 +88,7 @@ const selectedPresence = () =>
const controlled = ref(modelPresence() || selectedPresence());
const hasModel = ref(modelPresence());
onBeforeUpdate(() => {
hasLoader.value = Boolean(slots.loader);
hasModel.value = modelPresence();
controlled.value = hasModel.value || selectedPresence();
});
@@ -312,7 +314,7 @@ const virtualRows = computed<VirtualRow[]>(() => {
gap: 0,
});
});
if (slots.loader && props.loaderHeight > 0)
if (hasLoader.value && props.loaderHeight > 0)
push({ key: "loader", kind: "loader", height: props.loaderHeight, gap: 0 });
if (props.padding > 0)
push({ key: "pad-bottom", kind: "pad", height: props.padding, gap: 0 });