Commit 79885751e2410fc0070f771d54ba163da796103c
1 parent
7a9f6b28
fix issue #1846
Showing
1 changed file
with
22 additions
and
0 deletions
Show diff stats
src/components/tabs/tabs.vue
| @@ -310,6 +310,16 @@ | @@ -310,6 +310,16 @@ | ||
| 310 | }, | 310 | }, |
| 311 | handleResize(){ | 311 | handleResize(){ |
| 312 | this.updateNavScroll(); | 312 | this.updateNavScroll(); |
| 313 | + }, | ||
| 314 | + isInsideHiddenElement () { | ||
| 315 | + let parentNode = this.$el.parentNode; | ||
| 316 | + while(parentNode) { | ||
| 317 | + if (parentNode.style.display === 'none') { | ||
| 318 | + return parentNode; | ||
| 319 | + } | ||
| 320 | + parentNode = parentNode.parentNode; | ||
| 321 | + } | ||
| 322 | + return false; | ||
| 313 | } | 323 | } |
| 314 | }, | 324 | }, |
| 315 | watch: { | 325 | watch: { |
| @@ -329,6 +339,18 @@ | @@ -329,6 +339,18 @@ | ||
| 329 | this.showSlot = this.$slots.extra !== undefined; | 339 | this.showSlot = this.$slots.extra !== undefined; |
| 330 | this.observer = elementResizeDetectorMaker(); | 340 | this.observer = elementResizeDetectorMaker(); |
| 331 | this.observer.listenTo(this.$refs.navWrap, this.handleResize); | 341 | this.observer.listenTo(this.$refs.navWrap, this.handleResize); |
| 342 | + | ||
| 343 | + const hiddenParentNode = this.isInsideHiddenElement(); | ||
| 344 | + if (hiddenParentNode) { | ||
| 345 | + const mutationObserver = new MutationObserver(() => { | ||
| 346 | + if (hiddenParentNode.style.display !== 'none') { | ||
| 347 | + this.updateBar(); | ||
| 348 | + mutationObserver.disconnect(); | ||
| 349 | + } | ||
| 350 | + }); | ||
| 351 | + | ||
| 352 | + mutationObserver.observe(hiddenParentNode, { attributes: true, childList: true, characterData: true, attributeFilter: ['style'] }); | ||
| 353 | + } | ||
| 332 | }, | 354 | }, |
| 333 | beforeDestroy() { | 355 | beforeDestroy() { |
| 334 | this.observer.removeListener(this.$refs.navWrap, this.handleResize); | 356 | this.observer.removeListener(this.$refs.navWrap, this.handleResize); |