From f7da641fc32261ad34d64805cb44d3ebc4b14b66 Mon Sep 17 00:00:00 2001 From: krassowski <5832902+krassowski@users.noreply.github.com> Date: Sat, 27 Jan 2024 23:26:02 +0000 Subject: [PATCH] Do not scroll if fully visible in `smart` logic --- packages/ui-components/src/components/windowedlist.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/ui-components/src/components/windowedlist.ts b/packages/ui-components/src/components/windowedlist.ts index 31bab8f983fd..9d2b3c764bef 100644 --- a/packages/ui-components/src/components/windowedlist.ts +++ b/packages/ui-components/src/components/windowedlist.ts @@ -360,6 +360,7 @@ export abstract class WindowedListModel implements WindowedList.IModel { 0, itemMetadata.offset - size + itemMetadata.size ); + // Current offset (+/- padding) is the top edge of the viewport. const currentOffset = precomputed ? precomputed.currentOffset : this._scrollOffset; @@ -372,6 +373,8 @@ export abstract class WindowedListModel implements WindowedList.IModel { const crossingBottomEdge = bottomEdge > itemTop && bottomEdge < itemBottom; const crossingTopEdge = topEdge > itemTop && topEdge < itemBottom; + const isFullyWithinViewport = bottomEdge > itemBottom && topEdge < itemTop; + if (align === 'smart') { const edgeLessThanOneViewportAway = currentOffset >= bottomOffset - size && @@ -381,6 +384,7 @@ export abstract class WindowedListModel implements WindowedList.IModel { const hiddenPartTop = topEdge - itemTop; if ( + isFullyWithinViewport || (crossingBottomEdge && visiblePartBottom >= scrollDownThreshold) || (crossingTopEdge && hiddenPartTop < scrollUpThreshold) ) { @@ -401,7 +405,7 @@ export abstract class WindowedListModel implements WindowedList.IModel { } if (align === 'auto') { - if (bottomEdge > itemBottom && topEdge < itemTop) { + if (isFullyWithinViewport) { // No need to change the position, return the current offset. return currentOffset; } else if (alignPreference !== undefined) {