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>
32 lines
1.2 KiB
TypeScript
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')
|
|
})
|
|
})
|