Skip to content

Commit 98bf75e

Browse files
author
farfromrefuge
committed
fix: notify of disposing on disposeNativeView so that flavours can destroy their instances
1 parent a337eff commit 98bf75e

File tree

3 files changed

+29
-31
lines changed

3 files changed

+29
-31
lines changed

src/collectionview/index.android.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1174,6 +1174,7 @@ export class CollectionView extends CollectionViewBase {
11741174
this.enumerateViewHolders((v) => {
11751175
const view = v.view;
11761176
if (view) {
1177+
this.notifyForItemAtIndex(CollectionViewBase.itemDisposingEvent, view, v.getAdapterPosition(), view.bindingContext, v);
11771178
if (view.isLoaded) {
11781179
view.callUnloaded();
11791180
}

src/collectionview/index.ios.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -886,6 +886,7 @@ export class CollectionView extends CollectionViewBase {
886886

887887
private _removeContainer(cell: CollectionViewCell): void {
888888
const view = cell.view;
889+
this.notifyForItemAtIndex(CollectionViewBase.itemDisposingEvent, view, cell.currentIndex, view.bindingContext, cell);
889890
// This is to clear the StackLayout that is used to wrap ProxyViewContainer instances.
890891
if (!(view.parent instanceof CollectionView)) {
891892
this._removeView(view.parent);

src/collectionview/vue3/component.ts

Lines changed: 27 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -96,50 +96,46 @@ export const CollectionView = defineComponent({
9696
if (event.view) {
9797
event.view._batchUpdate(() => {
9898
// todo: handle the case where the slot is not found
99-
render(vnode!, container);
99+
render(vnode, container);
100100
});
101101
} else {
102102
// todo: handle the case where the slot is not found
103-
render(vnode!, container);
103+
render(vnode, container);
104104
}
105-
106105

107106
const cellEl = toRaw(vnode?.el?.nativeView);
108107
cellEl[LIST_CELL_ID] = id;
109108
cellEl[LIST_CELL_CONTAINER] = container;
110109
event.view = cellEl;
111-
112110
}
113111

114112
// render all realized templates as children
115-
const cellVNODES = () =>
116-
Object.entries(cells.value).map(([id, entry]) => {
117-
const vnodes: VNode[] = ctx.slots[entry.slotName]?.(entry.itemCtx) ?? [
118-
// default template is just a label
119-
h('Label', {
120-
text: entry.itemCtx[props.alias]
121-
})
122-
];
123-
124-
if (vnodes.length > 1) {
125-
warn(`ListView template must contain a single root element. Found: ${vnodes.length}. Only the first one will be used.`);
126-
}
127-
128-
const vnode: VNode = vnodes[0];
129-
// set the key to the list cell id, so we can find this cell later...
130-
vnode.key = id;
131-
132-
return vnode;
133-
});
113+
// const cellVNODES = () =>
114+
// Object.entries(cells.value).map(([id, entry]) => {
115+
// const vnodes: VNode[] = ctx.slots[entry.slotName]?.(entry.itemCtx) ?? [
116+
// // default template is just a label
117+
// h('Label', {
118+
// text: entry.itemCtx[props.alias]
119+
// })
120+
// ];
121+
122+
// if (vnodes.length > 1) {
123+
// warn(`ListView template must contain a single root element. Found: ${vnodes.length}. Only the first one will be used.`);
124+
// }
125+
126+
// const vnode: VNode = vnodes[0];
127+
// // set the key to the list cell id, so we can find this cell later...
128+
// vnode.key = id;
129+
130+
// return vnode;
131+
// });
134132

135133
return () =>
136-
h(
137-
'NativeCollectionView',
138-
{
139-
ref: collectionView,
140-
items: props.items,
141-
itemTemplates,
142-
onItemLoading
143-
});
134+
h('NativeCollectionView', {
135+
ref: collectionView,
136+
items: props.items,
137+
itemTemplates,
138+
onItemLoading
139+
});
144140
}
145141
});

0 commit comments

Comments
 (0)