From 79885751e2410fc0070f771d54ba163da796103c Mon Sep 17 00:00:00 2001 From: Kang Cheng Date: Sun, 29 Oct 2017 15:39:45 -0700 Subject: [PATCH] fix issue #1846 --- src/components/tabs/tabs.vue | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/components/tabs/tabs.vue b/src/components/tabs/tabs.vue index d99b9066..01b50b9e 100644 --- a/src/components/tabs/tabs.vue +++ b/src/components/tabs/tabs.vue @@ -310,6 +310,16 @@ }, handleResize(){ this.updateNavScroll(); + }, + isInsideHiddenElement () { + let parentNode = this.$el.parentNode; + while(parentNode) { + if (parentNode.style.display === 'none') { + return parentNode; + } + parentNode = parentNode.parentNode; + } + return false; } }, watch: { @@ -329,6 +339,18 @@ this.showSlot = this.$slots.extra !== undefined; this.observer = elementResizeDetectorMaker(); this.observer.listenTo(this.$refs.navWrap, this.handleResize); + + const hiddenParentNode = this.isInsideHiddenElement(); + if (hiddenParentNode) { + const mutationObserver = new MutationObserver(() => { + if (hiddenParentNode.style.display !== 'none') { + this.updateBar(); + mutationObserver.disconnect(); + } + }); + + mutationObserver.observe(hiddenParentNode, { attributes: true, childList: true, characterData: true, attributeFilter: ['style'] }); + } }, beforeDestroy() { this.observer.removeListener(this.$refs.navWrap, this.handleResize);