Files
ocis/web/packages/web-pkg/tests/unit/composables/rootOverscroll/useDisableRootOverscroll.spec.ts
Lukas Hirt e0dd0e4348 fix(web): [OCISDEV-1527] disable vertical page overscroll in file apps (#13140)
Scrolling inside an app such as OnlyOffice could make the whole page bounce
with it, exposing the blank page background behind the app frame. Set
overscroll-behavior-y: none on the root element while AppWrapper is mounted
and restore the previous value on unmount. The logic lives in a new
useDisableRootOverscroll composable, which is covered by unit tests.

Signed-off-by: Lukas Hirt <info@hirt.cz>
2026-10-13 21:18:12 +02:00

32 lines
1.2 KiB
TypeScript

import { useDisableRootOverscroll } from '../../../../src/composables/rootOverscroll'
import { getComposableWrapper } from '../../../../src/testing'
describe('useDisableRootOverscroll', () => {
const getRootOverscroll = () =>
document.documentElement.style.getPropertyValue('overscroll-behavior-y')
afterEach(() => {
document.documentElement.style.removeProperty('overscroll-behavior-y')
})
it('disables the vertical overscroll of the page root while mounted', () => {
const wrapper = getComposableWrapper(() => useDisableRootOverscroll())
expect(getRootOverscroll()).toBe('none')
wrapper.unmount()
})
it('removes the setting again when unmounted', () => {
const wrapper = getComposableWrapper(() => useDisableRootOverscroll())
wrapper.unmount()
expect(getRootOverscroll()).toBe('')
})
it('restores a previously set value when unmounted', () => {
document.documentElement.style.setProperty('overscroll-behavior-y', 'contain')
const wrapper = getComposableWrapper(() => useDisableRootOverscroll())
expect(getRootOverscroll()).toBe('none')
wrapper.unmount()
expect(getRootOverscroll()).toBe('contain')
})
})