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

Close tabs with middle mouse button #118

Closed
solodyagin opened this issue Apr 21, 2021 · 2 comments
Closed

Close tabs with middle mouse button #118

solodyagin opened this issue Apr 21, 2021 · 2 comments
Labels
feature New feature or request

Comments

@solodyagin
Copy link

solodyagin commented Apr 21, 2021

<template>
  <router-tab />
</template>

<script>
export default {
  mounted() {
    document.addEventListener('mousedown', this.middleClick)
  },
  destroyed() {
    document.removeEventListener('mousedown', this.middleClick)
  },
  methods: {
    middleClick(e) {
      if (e && (e.which == 2 || e.button == 4) && /router-tab__item/.test(e.target.className)) {
        const to = e.target.closest('.router-tab__item').__vue__.to,
          closable = this.$tabs.items.reduce((r, item) => ({ ...r, [item.to]: (item.closable ??= true) }), {})
        if (closable[to]) this.$tabs.close(to)
      }
    }
  }
}
</script>
@solodyagin solodyagin added the feature New feature or request label Apr 21, 2021
@bhuh12
Copy link
Owner

bhuh12 commented May 9, 2021

v1.2.6 already supports this feature

@solodyagin
Copy link
Author

Thank You

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants