Skip to content
This repository has been archived by the owner on Nov 30, 2020. It is now read-only.

Commit

Permalink
fix(tab-bar): add a built-in scroller if the default slot is not a sc…
Browse files Browse the repository at this point in the history
…roller (#313)

fixes #312
  • Loading branch information
tychenjiajun authored Jul 1, 2019
1 parent e6d231d commit 0650e3d
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
14 changes: 13 additions & 1 deletion components/tabs/TabBar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,18 @@
role="tablist"
@MDCTabBar:activated="onActivated"
>
<slot />
<slot v-if="$slots.default[0].tag.includes('m-tab-scroller')" />
<!-- todo: it doesn't work with <div class='mdc-tab-scroller'> but only work with our own m-tab-scroller component. This need to be enhanced. -->
<div
v-else
class="mdc-tab-scroller"
>
<div class="mdc-tab-scroller__scroll-area">
<div class="mdc-tab-scroller__scroll-content">
<slot />
</div>
</div>
</div>
</div>
</template>

Expand Down Expand Up @@ -53,6 +64,7 @@ export default {
}
},
mounted () {
console.log(this.$slots.default[0].tag)
this.mdcTabBar = MDCTabBar.attachTo(this.$el)
this.mdcTabBar.focusOnActivate = this.focusOnActivate
this.mdcTabBar.useAutomaticActivation = this.useAutomaticActivation
Expand Down
1 change: 0 additions & 1 deletion components/tabs/TabIndicator.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import { MDCTabIndicator } from '@material/tab-indicator'
import { baseComponentMixin, themeClassMixin } from '../base'
export default {
name: 'TabIndicator',
mixins: [baseComponentMixin, themeClassMixin],
props: {
fade: {
Expand Down
1 change: 0 additions & 1 deletion components/tabs/TabScroller.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import { MDCTabScroller } from '@material/tab-scroller'
import { baseComponentMixin, themeClassMixin } from '../base'
export default {
name: 'TabScroller',
mixins: [baseComponentMixin, themeClassMixin],
data () {
return {
Expand Down

0 comments on commit 0650e3d

Please sign in to comment.