Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
51 changes: 51 additions & 0 deletions src/cdk/overlay/scroll/block-scroll-strategy.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,57 @@ describe('BlockScrollStrategy', () => {
}),
);

it(
`should't do anything if the page isn't scrollable while zoomed out`,
skipIOS(() => {
if (platform.FIREFOX) {
// style.zoom is only supported from Firefox 126
return;
}

forceScrollElement.style.display = 'none';
document.body.style.zoom = '75%';
overlayRef.attach(componentPortal);
expect(document.body.scrollWidth).toBeGreaterThan(window.innerWidth);
expect(documentElement.classList).not.toContain('cdk-global-scrollblock');
overlayRef.detach();
document.body.style.zoom = '100%';

document.documentElement.style.zoom = '75%';
overlayRef.attach(componentPortal);
expect(document.body.scrollWidth).toBeGreaterThan(window.innerWidth);
expect(documentElement.classList).not.toContain('cdk-global-scrollblock');
document.documentElement.style.zoom = '100%';
}),
);

it(
`should add cdk-global-scrollblock while zoomed in`,
skipIOS(() => {
if (platform.FIREFOX) {
// style.zoom is only supported from Firefox 126
return;
}

forceScrollElement.style.width = window.innerWidth - 20 + 'px';
forceScrollElement.style.height = window.innerHeight - 20 + 'px';
overlayRef.attach(componentPortal);
expect(documentElement.classList).not.toContain('cdk-global-scrollblock');
overlayRef.detach();

document.body.style.zoom = '200%';
overlayRef.attach(componentPortal);
expect(documentElement.classList).toContain('cdk-global-scrollblock');
document.body.style.zoom = '100%';
overlayRef.detach();

document.documentElement.style.zoom = '200%';
overlayRef.attach(componentPortal);
expect(documentElement.classList).toContain('cdk-global-scrollblock');
document.documentElement.style.zoom = '100%';
}),
);

it('should keep the content width', () => {
forceScrollElement.style.width = '100px';

Expand Down
4 changes: 2 additions & 2 deletions src/cdk/overlay/scroll/block-scroll-strategy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,8 @@ export class BlockScrollStrategy implements ScrollStrategy {
return false;
}

const body = this._document.body;
const rootElement = this._document.documentElement;
const viewport = this._viewportRuler.getViewportSize();
return body.scrollHeight > viewport.height || body.scrollWidth > viewport.width;
return rootElement.scrollHeight > viewport.height || rootElement.scrollWidth > viewport.width;
}
}
Loading