🌐 AI搜索 & 代理 主页
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 12 additions & 15 deletions src/components/tabs/tab.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,14 @@ export const BTab = /*#__PURE__*/ Vue.extend({
props,
data() {
return {
localActive: this[MODEL_PROP_NAME_ACTIVE] && !this.disabled,
show: false
localActive: this[MODEL_PROP_NAME_ACTIVE] && !this.disabled
}
},
computed: {
// For parent sniffing of child
_isTab() {
return true
},
tabClasses() {
const { localActive: active, disabled } = this

Expand All @@ -80,17 +83,9 @@ export const BTab = /*#__PURE__*/ Vue.extend({
},
computedLazy() {
return this.bvTabs.lazy || this.lazy
},
// For parent sniffing of child
_isTab() {
return true
}
},
watch: {
localActive(newValue) {
// Make `active` prop work with `.sync` modifier
this.$emit(MODEL_EVENT_NAME_ACTIVE, newValue)
},
[MODEL_PROP_NAME_ACTIVE](newValue, oldValue) {
if (newValue !== oldValue) {
if (newValue) {
Expand All @@ -114,13 +109,15 @@ export const BTab = /*#__PURE__*/ Vue.extend({
firstTab()
}
}
},
localActive(newValue) {
// Make `active` prop work with `.sync` modifier
this.$emit(MODEL_EVENT_NAME_ACTIVE, newValue)
}
},
mounted() {
// Inform b-tabs of our presence
// Inform `<b-tabs>` of our presence
this.registerTab()
// Initially show on mount if active and not disabled
this.show = this.localActive
},
updated() {
// Force the tab button content to update (since slots are not reactive)
Expand All @@ -130,8 +127,8 @@ export const BTab = /*#__PURE__*/ Vue.extend({
updateButton(this)
}
},
destroyed() {
// inform b-tabs of our departure
beforeDestroy() {
// Inform `<b-tabs>` of our departure
this.unregisterTab()
},
methods: {
Expand Down
5 changes: 1 addition & 4 deletions src/components/tabs/tab.spec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { mount } from '@vue/test-utils'
import { waitNT, waitRAF } from '../../../tests/utils'
import { waitNT } from '../../../tests/utils'
import { BTab } from './tab'

describe('tab', () => {
Expand Down Expand Up @@ -31,7 +31,6 @@ describe('tab', () => {

expect(wrapper.vm._isTab).toBe(true)
expect(wrapper.vm.localActive).toBe(false)
expect(wrapper.vm.show).toBe(false)

wrapper.destroy()
})
Expand Down Expand Up @@ -86,15 +85,13 @@ describe('tab', () => {

await wrapper.setData({ localActive: true })
await waitNT(wrapper.vm)
await waitRAF()

expect(wrapper.classes()).toContain('active')
expect(wrapper.classes()).not.toContain('disabled')
expect(wrapper.classes()).not.toContain('card-body')

await wrapper.setData({ localActive: false })
await waitNT(wrapper.vm)
await waitRAF()

expect(wrapper.classes()).not.toContain('active')
expect(wrapper.classes()).not.toContain('disabled')
Expand Down
Loading