Skip to content

Commit ed80791

Browse files
committed
fix(content): add an internal method to recalculate dimensions
1 parent 1c89cf0 commit ed80791

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

core/src/components.d.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -868,6 +868,10 @@ export namespace Components {
868868
* Get the element where the actual scrolling takes place. This element can be used to subscribe to `scroll` events or manually modify `scrollTop`. However, it's recommended to use the API provided by `ion-content`: i.e. Using `ionScroll`, `ionScrollStart`, `ionScrollEnd` for scrolling events and `scrollToPoint()` to scroll the content into a certain point.
869869
*/
870870
"getScrollElement": () => Promise<HTMLElement>;
871+
/**
872+
* Recalculate content dimensions. Called by overlays (e.g., popover) when sibling elements like headers or footers have finished rendering and their heights are available, ensuring accurate offset-top calculations.
873+
*/
874+
"recalculateDimensions": () => Promise<void>;
871875
/**
872876
* Scroll by a specified X/Y distance in the component.
873877
* @param x The amount to scroll by on the horizontal axis.

core/src/components/content/content.tsx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,17 @@ export class Content implements ComponentInterface {
254254
}
255255
}
256256

257+
/**
258+
* Recalculate content dimensions. Called by overlays (e.g., popover) when
259+
* sibling elements like headers or footers have finished rendering and their
260+
* heights are available, ensuring accurate offset-top calculations.
261+
* @internal
262+
*/
263+
@Method()
264+
async recalculateDimensions(): Promise<void> {
265+
readTask(() => this.readDimensions());
266+
}
267+
257268
private readDimensions() {
258269
const page = getPageElement(this.el);
259270
const top = Math.max(this.el.offsetTop, 0);

0 commit comments

Comments
 (0)