@@ -216,6 +216,7 @@ export const computeNewArray = <T extends ListScrollSourceItemWithDate<D>, D ext
216
216
if ( ! _item . getProgressQuery ) _item . getProgressQuery = getProgressQuery ( item ) ;
217
217
if ( ! _item . tags ) _item . tags = getTags ( item , _item . type ) ;
218
218
219
+ _item . key = `${ _item . type } -${ _item . id } ` ;
219
220
_item . date = getDate ( item , array , index , dateFn ) ;
220
221
_item . meta = {
221
222
source : item ,
@@ -291,7 +292,7 @@ export const useListScrollEvents = (
291
292
) => {
292
293
const onScroll : OnScroll = async listRef => {
293
294
const _listRef = isRef ( listRef ) ? listRef . value : listRef ;
294
- const key = data . value [ data . value . length - 1 ] . id ;
295
+ const { key } = data . value [ data . value . length - 1 ] ;
295
296
await callback ( {
296
297
page : pagination . value ?. page ? pagination . value . page + 1 : 0 ,
297
298
} ) ;
@@ -335,7 +336,8 @@ export const addAllLoaded = (items: Ref<ListScrollItem[]>, pagination: Ref<Store
335
336
if ( array [ array . length - 1 ] . type === ListScrollItemType . AllLoaded ) return array ;
336
337
const type = ListScrollItemType . AllLoaded ;
337
338
const index = items . value . length ;
338
- const allLoaded : ListScrollItem = { id : type , type, index, key : `${ index } -${ type } ` } ;
339
+ // All loaded should be unique so id and key are based on the type
340
+ const allLoaded : ListScrollItem = { id : type , type, index, key : type } ;
339
341
return [ ...array , allLoaded ] ;
340
342
} ) ;
341
343
} ;
@@ -353,7 +355,8 @@ export const addLoadMore = (items: Ref<ListScrollItem[]>, pagination: Ref<StoreP
353
355
if ( array [ array . length - 1 ] . type === ListScrollItemType . LoadMore ) return array ;
354
356
const type = ListScrollItemType . LoadMore ;
355
357
const index = items . value . length ;
356
- const loadMore : ListScrollItem = { id : type , type, index, key : `${ index } -${ type } ` } ;
358
+ // Load more should be unique so id and key are based on the type
359
+ const loadMore : ListScrollItem = { id : type , type, index, key : type } ;
357
360
return [ ...array , loadMore ] ;
358
361
} ) ;
359
362
} ;
0 commit comments