From 5db627698e8407c12e485840d47a9923007d6f6f Mon Sep 17 00:00:00 2001 From: Dominik Pschenitschni Date: Mon, 30 Jan 2023 11:35:14 +0100 Subject: [PATCH] feat(useScrollLock): detect parent with overflow auto --- packages/core/useScrollLock/index.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/core/useScrollLock/index.ts b/packages/core/useScrollLock/index.ts index 7768478f26c..11bd5a27f54 100644 --- a/packages/core/useScrollLock/index.ts +++ b/packages/core/useScrollLock/index.ts @@ -6,7 +6,12 @@ import { useEventListener } from '../useEventListener' function checkOverflowScroll(ele: Element): boolean { const style = window.getComputedStyle(ele) - if (style.overflowX === 'scroll' || style.overflowY === 'scroll') { + if ( + style.overflowX === 'scroll' + || style.overflowY === 'scroll' + || (style.overflowX === 'auto' && ele.clientHeight < ele.scrollHeight) + || (style.overflowY === 'auto' && ele.clientWidth < ele.scrollWidth) + ) { return true } else {