handleTabKeyboardSelect add params init

So, when mounted, the event not emit.
This commit is contained in:
Aresn 2018-05-18 10:47:04 +08:00 committed by GitHub
parent 38ab744203
commit 8b41022044
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -236,7 +236,8 @@
const nextTab = getNextTab(this.navList, this.focusedKey, direction); const nextTab = getNextTab(this.navList, this.focusedKey, direction);
this.focusedKey = nextTab.name; this.focusedKey = nextTab.name;
}, },
handleTabKeyboardSelect(){ handleTabKeyboardSelect(init = false){
if (init) return;
const focused = this.focusedKey || 0; const focused = this.focusedKey || 0;
const index = this.navList.findIndex(({name}) => name === focused); const index = this.navList.findIndex(({name}) => name === focused);
this.handleChange(index); this.handleChange(index);
@ -416,7 +417,7 @@
this.mutationObserver.observe(hiddenParentNode, { attributes: true, childList: true, characterData: true, attributeFilter: ['style'] }); this.mutationObserver.observe(hiddenParentNode, { attributes: true, childList: true, characterData: true, attributeFilter: ['style'] });
} }
this.handleTabKeyboardSelect(); this.handleTabKeyboardSelect(true);
}, },
beforeDestroy() { beforeDestroy() {
this.observer.removeListener(this.$refs.navWrap, this.handleResize); this.observer.removeListener(this.$refs.navWrap, this.handleResize);