From c1ee395f80c05de8317588b07f34a65c5b95c42c Mon Sep 17 00:00:00 2001 From: Jeremy Jackson Date: Thu, 17 Oct 2019 15:01:44 +0000 Subject: Skip hidden dropdowns while focusing (#29523) --- js/src/dropdown.js | 2 ++ js/src/util/index.js | 9 ++++++--- 2 files changed, 8 insertions(+), 3 deletions(-) (limited to 'js/src') diff --git a/js/src/dropdown.js b/js/src/dropdown.js index 06a271ef8..4504d61e0 100644 --- a/js/src/dropdown.js +++ b/js/src/dropdown.js @@ -9,6 +9,7 @@ import { getjQuery, getElementFromSelector, isElement, + isVisible, makeArray, noop, typeCheckConfig @@ -478,6 +479,7 @@ class Dropdown { } const items = makeArray(SelectorEngine.find(Selector.VISIBLE_ITEMS, parent)) + .filter(isVisible) if (!items.length) { return diff --git a/js/src/util/index.js b/js/src/util/index.js index 150b4f877..8a5ae2156 100644 --- a/js/src/util/index.js +++ b/js/src/util/index.js @@ -138,9 +138,12 @@ const isVisible = element => { } if (element.style && element.parentNode && element.parentNode.style) { - return element.style.display !== 'none' && - element.parentNode.style.display !== 'none' && - element.style.visibility !== 'hidden' + const elementStyle = getComputedStyle(element) + const parentNodeStyle = getComputedStyle(element.parentNode) + + return elementStyle.display !== 'none' && + parentNodeStyle.display !== 'none' && + elementStyle.visibility !== 'hidden' } return false -- cgit v1.2.3