Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion packages/main/src/TableGrowing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
TABLE_MORE,
TABLE_MORE_DESCRIPTION,
} from "./generated/i18n/i18n-defaults.js";
import { findVerticalScrollContainer } from "./TableUtils.js";

// The documentation should be similar to the Table.ts class documentation!
// Please only use that style where it uses markdown and the documentation is more readable.
Expand Down Expand Up @@ -225,7 +226,10 @@ class TableGrowing extends UI5Element implements ITableGrowing {
*/
_getIntersectionObserver(): IntersectionObserver {
if (!this._observer) {
this._observer = new IntersectionObserver(this._onIntersection.bind(this), { root: document });
this._observer = new IntersectionObserver(this._onIntersection.bind(this), {
root: findVerticalScrollContainer(this._table?._endRow ?? document.body),
rootMargin: "5px",
});
}
return this._observer;
}
Expand Down
6 changes: 5 additions & 1 deletion packages/main/src/TableUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,11 @@ const findRowInPath = (composedPath: Array<EventTarget>) => {
const findVerticalScrollContainer = (element: HTMLElement): HTMLElement => {
while (element) {
const { overflowY } = window.getComputedStyle(element);
if (overflowY === "auto" || overflowY === "scroll") {
if (overflowY === "auto") {
if (element.scrollHeight > element.clientHeight) {
return element;
}
} else if (overflowY === "scroll") {
return element;
}

Expand Down