From c89d5ee096c28e4355be946a6d40115dfa74bc60 Mon Sep 17 00:00:00 2001 From: neverland Date: Tue, 7 Jan 2020 17:03:21 +0800 Subject: [PATCH] fix(Tabs): can not render line when wrapper is fixed (#5496) --- src/utils/dom/style.ts | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/utils/dom/style.ts b/src/utils/dom/style.ts index db080c998..8c725a564 100644 --- a/src/utils/dom/style.ts +++ b/src/utils/dom/style.ts @@ -1,5 +1,11 @@ export function isHidden(element: HTMLElement) { - return ( - window.getComputedStyle(element).display === 'none' || element.offsetParent === null - ); + const style = window.getComputedStyle(element); + const isHidden = style.display === 'none'; + + // offsetParent returns null in the following situations: + // 1. The element or its parent element has the display property set to none. + // 2. The element has the position property set to fixed + const isParentHidden = element.offsetParent === null && style.position !== 'fixed'; + + return isHidden || isParentHidden; }