diff --git a/changelog/unreleased/bugfix-endless-lazy-loading-when-sorting b/changelog/unreleased/bugfix-endless-lazy-loading-when-sorting new file mode 100644 index 00000000000..0152b9b8074 --- /dev/null +++ b/changelog/unreleased/bugfix-endless-lazy-loading-when-sorting @@ -0,0 +1,6 @@ +Bugfix: Endless lazy loading indicator after sorting file table + +The endless lazy loading indicator when sorting the file table and re-entering it has been fixed. + +https://github.com/owncloud/web/issues/6434 +https://github.com/owncloud/web/pull/8988 diff --git a/packages/design-system/src/composables/useIsVisible/index.ts b/packages/design-system/src/composables/useIsVisible/index.ts index 09902e97ce8..05692ee483d 100644 --- a/packages/design-system/src/composables/useIsVisible/index.ts +++ b/packages/design-system/src/composables/useIsVisible/index.ts @@ -17,7 +17,14 @@ export const useIsVisible = ({ target, mode = 'show', rootMargin = '100px' }) => const isVisible = ref(false) const observer = new IntersectionObserver( - ([{ isIntersecting }]) => { + (intersectionObserverEntries: IntersectionObserverEntry[]) => { + /** + * In some edge cases intersectionObserverEntries contains 2 entries with the first one having wrong rootBounds. + * This happens for some reason when the table is being re-sorted immediately after being rendered. + * Therefore we always check the last entry for isIntersecting. + */ + const isIntersecting = intersectionObserverEntries.at(-1).isIntersecting + isVisible.value = isIntersecting /** * if given mode is `showHide` we need to keep the observation alive.