Skip to content

Commit 410ef74

Browse files
committed
fix(vue3): itemTemplateSelector don't select correct template in recycling
1 parent d52239d commit 410ef74

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/collectionview/vue3/component.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ export const CollectionView = defineComponent({
5353
}
5454
}));
5555

56-
const getSlotName = (itemCtx: ListItem, index: number, items: ListItem[]) => props.itemTemplateSelector?.(itemCtx, index, items) ?? 'default';
56+
const getSlotName = (item: any, index: number, items: ListItem[]) => props.itemTemplateSelector?.(item, index, items) ?? 'default';
5757

5858
const collectionView = ref<any & { nativeView: NSCollectionView }>(null);
5959

@@ -80,7 +80,7 @@ export const CollectionView = defineComponent({
8080
// const itemCtx: ListItem = getItemCtx(props.items instanceof ObservableArray ? props.items.getItem(index) : props.items[index], index, props.alias, props.itemIdGenerator);
8181

8282
// update the cell data with the current row
83-
const slotName = getSlotName(itemCtx, index, event.object.items);
83+
const slotName = getSlotName(item, index, event.object.items);
8484
cells.value[id] = {
8585
itemCtx,
8686
slotName
@@ -135,7 +135,8 @@ export const CollectionView = defineComponent({
135135
ref: collectionView,
136136
items: props.items,
137137
itemTemplates,
138-
onItemLoading
138+
onItemLoading,
139+
itemTemplateSelector: (item, index, items) => getSlotName(item, index, items)
139140
});
140141
}
141142
});

0 commit comments

Comments
 (0)