Skip to content

Commit 3a58aa7

Browse files
committed
fix(content): adjusted PR requests
1 parent aa6bd72 commit 3a58aa7

20 files changed

Lines changed: 15 additions & 19 deletions

core/src/components/content/content.tsx

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ export class Content implements ComponentInterface {
3636
private backgroundContentEl?: HTMLElement;
3737
private isMainContent = true;
3838
private resizeTimeout: ReturnType<typeof setTimeout> | null = null;
39+
private observerResizeTimeout: ReturnType<typeof setTimeout> | null = null;
3940
private inheritedAttributes: Attributes = {};
4041

4142
private tabsElement: HTMLElement | null = null;
@@ -446,10 +447,14 @@ export class Content implements ComponentInterface {
446447
}
447448

448449
if ('ResizeObserver' in window) {
449-
let timeout: any;
450450
this.resizeObserver = new ResizeObserver(() => {
451-
clearTimeout(timeout);
452-
timeout = setTimeout(() => this.resize(), 100);
451+
if (this.observerResizeTimeout !== null) {
452+
clearTimeout(this.observerResizeTimeout);
453+
}
454+
this.observerResizeTimeout = setTimeout(() => {
455+
this.observerResizeTimeout = null;
456+
this.resize();
457+
}, 100);
453458
});
454459
}
455460

@@ -486,6 +491,10 @@ export class Content implements ComponentInterface {
486491
}
487492

488493
private disconnectObservers() {
494+
if (this.observerResizeTimeout !== null) {
495+
clearTimeout(this.observerResizeTimeout);
496+
this.observerResizeTimeout = null;
497+
}
489498
if (this.mutationObserver) {
490499
this.mutationObserver.disconnect();
491500
this.mutationObserver = null;
@@ -503,17 +512,10 @@ export class Content implements ComponentInterface {
503512

504513
this.resizeObserver.disconnect();
505514

506-
const headers = this.el.parentElement.querySelectorAll('ion-header');
507-
const footers = this.el.parentElement.querySelectorAll('ion-footer');
515+
const targets = this.el.parentElement.querySelectorAll(':scope > ion-header, :scope > ion-footer');
508516

509517
const observer = this.resizeObserver;
510-
511-
if (observer === null || observer === undefined) {
512-
return;
513-
}
514-
515-
headers.forEach((header) => observer.observe(header));
516-
footers.forEach((footer) => observer.observe(footer));
518+
targets.forEach((target) => observer.observe(target));
517519
}
518520

519521
private onScrollStart() {

core/src/components/content/test/auto-offset/content.e2e.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { expect } from '@playwright/test';
22
import { test, configs } from '@utils/test/playwright';
33

4-
configs({ modes: ['ios'] }).forEach(({ title, screenshot, config }) => {
4+
configs().forEach(({ title, screenshot, config }) => {
55
test.describe(title('content: auto offset'), () => {
66
test('should not have visual regressions', async ({ page }) => {
77
await page.goto(`/src/components/content/test/auto-offset`, config);
@@ -36,12 +36,6 @@ configs({ modes: ['ios'] }).forEach(({ title, screenshot, config }) => {
3636

3737
await expect(content).not.toHaveCSS('--offset-bottom', before);
3838

39-
const after = await content.evaluate((el: HTMLElement) =>
40-
getComputedStyle(el).getPropertyValue('--offset-bottom')
41-
);
42-
43-
expect(after).not.toBe(before);
44-
4539
await expect(page).toHaveScreenshot(screenshot(`content-auto-offset-footer-updated`));
4640
});
4741
});
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading

0 commit comments

Comments
 (0)