From 36df5ff8cb64ba9cfc0e94398e65d3d09c6fded2 Mon Sep 17 00:00:00 2001 From: Aleksandra Danilina Date: Fri, 13 Dec 2024 14:29:51 +0100 Subject: [PATCH] chore: Extend overflow detection --- src/browser-scripts/scroll.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/browser-scripts/scroll.ts b/src/browser-scripts/scroll.ts index 2dd791a..80c6a11 100644 --- a/src/browser-scripts/scroll.ts +++ b/src/browser-scripts/scroll.ts @@ -14,9 +14,14 @@ export function scrollAction( if (!element) { throw new Error('Element ' + selector + ' has not been found at the page'); } - if (!['auto', 'scroll'].includes(getComputedStyle(element).overflow) && element !== document.documentElement) { + + const overflowDirection = + action === 'scrollToOffset' ? 'overflow' : action === 'scrollToBottom' ? 'overflowY' : 'overflowX'; + const overflowStyles = getComputedStyle(element)[overflowDirection].split(' '); + if (!overflowStyles.includes('auto') && !overflowStyles.includes('scroll') && element !== document.documentElement) { throw new Error('Element ' + selector + ' is not scrollable'); } + switch (action) { case 'scrollToOffset': if (!offset) {