Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Impossible to set :md-active-tab when using :to #2335

Open
remi-blaise opened this issue Jul 30, 2021 · 0 comments
Open

Impossible to set :md-active-tab when using :to #2335

remi-blaise opened this issue Jul 30, 2021 · 0 comments

Comments

@remi-blaise
Copy link

remi-blaise commented Jul 30, 2021

Steps to reproduce

<md-tabs :md-active-tab="activeTab">
  <md-tab id="Studio" :to="{ name: 'Studio' }" md-icon="store"></md-tab>
  <md-tab id="Orders" :to="{ name: 'Orders' }" md-icon="paid"></md-tab>
</md-tabs>

What is expected?

:md-active-tab value should overrule, especially if md-sync-route = false.

What is actually happening?

:md-active-tab value is ignored.

Workaround

<script>
export default {
  computed: {
    activeTab() {
      return this.$router.currentRoute.path.startsWith('/orders') ? 'paid' : 'store'
    },
  },
  methods: {
    updateActiveTab() {
      setTimeout(() => {
        const i = document.querySelectorAll('.md-tabs-navigation i')

        for (const o of i) {
          o.style.color = this.activeTab === o.textContent ? '#448aff' : 'black'
        }
      })
    },
  },
  mounted() {
    this.updateActiveTab()
  },
  updated() {
    this.updateActiveTab()
  },
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant