Skip to content

Commit 95ddd56

Browse files
committed
fix(content): adjusted PR requests
1 parent c080622 commit 95ddd56

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;
@@ -441,10 +442,14 @@ export class Content implements ComponentInterface {
441442
}
442443

443444
if ('ResizeObserver' in window) {
444-
let timeout: any;
445445
this.resizeObserver = new ResizeObserver(() => {
446-
clearTimeout(timeout);
447-
timeout = setTimeout(() => this.resize(), 100);
446+
if (this.observerResizeTimeout !== null) {
447+
clearTimeout(this.observerResizeTimeout);
448+
}
449+
this.observerResizeTimeout = setTimeout(() => {
450+
this.observerResizeTimeout = null;
451+
this.resize();
452+
}, 100);
448453
});
449454
}
450455

@@ -481,6 +486,10 @@ export class Content implements ComponentInterface {
481486
}
482487

483488
private disconnectObservers() {
489+
if (this.observerResizeTimeout !== null) {
490+
clearTimeout(this.observerResizeTimeout);
491+
this.observerResizeTimeout = null;
492+
}
484493
if (this.mutationObserver) {
485494
this.mutationObserver.disconnect();
486495
this.mutationObserver = null;
@@ -498,17 +507,10 @@ export class Content implements ComponentInterface {
498507

499508
this.resizeObserver.disconnect();
500509

501-
const headers = this.el.parentElement.querySelectorAll('ion-header');
502-
const footers = this.el.parentElement.querySelectorAll('ion-footer');
510+
const targets = this.el.parentElement.querySelectorAll(':scope > ion-header, :scope > ion-footer');
503511

504512
const observer = this.resizeObserver;
505-
506-
if (observer === null || observer === undefined) {
507-
return;
508-
}
509-
510-
headers.forEach((header) => observer.observe(header));
511-
footers.forEach((footer) => observer.observe(footer));
513+
targets.forEach((target) => observer.observe(target));
512514
}
513515

514516
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)