Skip to content

Commit

Permalink
fix(ui5-table): correct load-more event on mode change (#9434)
Browse files Browse the repository at this point in the history
If the `ui5-table` is made with `mode=Growing`, and then the mode is changed to `None` and back to `Growing`, the `load-more` event is not fired anymore. This is because the observed element by IntersectionObserver is not in the DOM anymore because it is conditionally rendered. To fix this, we reset the `tableEndObserved` flag when the mode changes, so the observed element is set again correctly when the DOM is ready.

Fixes: #8052
  • Loading branch information
nnaydenow authored Jul 10, 2024
1 parent 5404f99 commit 55aa134
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions packages/compat/src/Table.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import UI5Element from "@ui5/webcomponents-base/dist/UI5Element.js";
import type { ChangeInfo } from "@ui5/webcomponents-base/dist/UI5Element.js";
import customElement from "@ui5/webcomponents-base/dist/decorators/customElement.js";
import property from "@ui5/webcomponents-base/dist/decorators/property.js";
import event from "@ui5/webcomponents-base/dist/decorators/event.js";
Expand Down Expand Up @@ -927,6 +928,13 @@ class Table extends UI5Element {
this._loadMoreActive = false;
}

onInvalidation(change: ChangeInfo) {
if (change.type === "property" && change.name === "growing") {
this.tableEndObserved = false;
this.getIntersectionObserver().disconnect();
}
}

_onLoadMoreClick() {
this.fireEvent("load-more");
}
Expand Down

0 comments on commit 55aa134

Please sign in to comment.