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

Fix Tab-Group Header not displayed #2557

Merged
merged 11 commits into from
Jul 13, 2024
5 changes: 5 additions & 0 deletions packages/vue-components/src/Dropdown.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
data-bs-toggle="dropdown"
>
<slot name="header"></slot>
<span>{{ tabGroupHeader }}</span>
</a>
</slot>
<slot name="dropdown-menu" :class="[{ 'show': show }, { 'dropdown-menu-end': menuAlignRight }]">
Expand Down Expand Up @@ -70,6 +71,10 @@ export default {
type: String,
default: 'light',
},
tabGroupHeader: {
type: String,
default: '',
},
menuAlignRight: {
type: Boolean,
default: false,
Expand Down
2 changes: 1 addition & 1 deletion packages/vue-components/src/Tabset.vue
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
v-else
:key="index"
class="nav-item"
:header="t.headerRendered"
:tab-group-header="t.headerRendered"
:class="{active:t.active}"
:disabled="t.disabled"
>
Expand Down
2 changes: 0 additions & 2 deletions packages/vue-components/src/__tests__/Dropdown.spec.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import { mount } from '@vue/test-utils';
import Dropdown from '../Dropdown.vue';
import Submenu from '../Submenu.vue';

const DEFAULT_STUBS = {
'dropdown': Dropdown,
'submenu': Submenu,
};

const DROPDOWN = `
Expand Down
78 changes: 78 additions & 0 deletions packages/vue-components/src/__tests__/Tabset.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
import { mount } from '@vue/test-utils';
import Tab from '../Tab.vue';
import TabGroup from '../TabGroup.vue';
import Tabset from '../Tabset.vue';

const DEFAULT_STUBS = {
'tab': Tab,
'tab-group': TabGroup,
};

const TABSET_HEADER = 'Tabset Header';

const TAB_COMPONENT = `
<tab header="Tab 1">
Text in the first tab
</tab>
<tab header="Tab 2">
Text in the second tab
</tab>
`;

const TABGROUP_COMPONENT = `
<tab-group header="Third tab group :milky_way:">
<tab header="Stars :star:">
Some stuff about stars ...
</tab>
<tab header="Disabled Moon :new_moon:" disabled>
</tab>
</tab-group>
<tab-group header="Disabled fourth tab group" disabled>
<tab header="Hidden tab">
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla ullamcorper ultrices lobortis.
</tab>
</tab-group>
`;

const TAB_AND_TABGROUP_COMPONENT = `
${TAB_COMPONENT}
${TABGROUP_COMPONENT}
`;

describe('Tabset (Tabs) with Tab and Tab-Group Components', () => {
test('renders tabset with tabs', () => {
const wrapper = mount(Tabset, {
slots: {
header: TABSET_HEADER,
default: TAB_COMPONENT,
},
stubs: DEFAULT_STUBS,
});

expect(wrapper.element).toMatchSnapshot();
});

test('renders tabset with tab-group', () => {
const wrapper = mount(Tabset, {
slots: {
header: TABSET_HEADER,
default: TABGROUP_COMPONENT,
},
stubs: DEFAULT_STUBS,
});

expect(wrapper.element).toMatchSnapshot();
});

test('renders tabset with both tabs and tab-group', () => {
const wrapper = mount(Tabset, {
slots: {
header: TABSET_HEADER,
default: TAB_AND_TABGROUP_COMPONENT,
},
stubs: DEFAULT_STUBS,
});

expect(wrapper.element).toMatchSnapshot();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,244 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Tabset (Tabs) with Tab and Tab-Group Components renders tabset with both tabs and tab-group 1`] = `
<div
class="printable-tabs"
>
<ul
class="nav nav-tabs d-print-none nav-tabs"
role="tablist"
/>

<div
class="tab-content"
>
<div
class="tab-pane active printable-tab-pane tab-pane-hide"
role="tabpanel"
>
<div
class="nav-tabs printable-tab-header"
>
<div
class="nav-link active"
/>
</div>

Text in the first tab

<hr />
</div>

<div
class="tab-pane active printable-tab-pane tab-pane-hide"
role="tabpanel"
>
<div
class="nav-tabs printable-tab-header"
>
<div
class="nav-link active"
/>
</div>

Text in the second tab

<hr />
</div>

<div
class="printable-tab-group"
>
<div
class="printable-tab-group-header"
/>

<div
class="tab-pane active printable-tab-pane tab-pane-hide"
role="tabpanel"
>
<div
class="nav-tabs printable-tab-header"
>
<div
class="nav-link active"
/>
</div>

Some stuff about stars ...

<hr />
</div>

<div
class="tab-pane active printable-tab-pane tab-pane-hide"
role="tabpanel"
>
<div
class="nav-tabs printable-tab-header"
>
<div
class="nav-link active"
/>
</div>

<hr />
</div>
</div>

<div
class="printable-tab-group"
>
<div
class="printable-tab-group-header"
/>

<div
class="tab-pane active printable-tab-pane tab-pane-hide"
role="tabpanel"
>
<div
class="nav-tabs printable-tab-header"
>
<div
class="nav-link active"
/>
</div>

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla ullamcorper ultrices lobortis.

<hr />
</div>
</div>
</div>
</div>
`;

exports[`Tabset (Tabs) with Tab and Tab-Group Components renders tabset with tab-group 1`] = `
<div
class="printable-tabs"
>
<ul
class="nav nav-tabs d-print-none nav-tabs"
role="tablist"
/>

<div
class="tab-content"
>
<div
class="printable-tab-group"
>
<div
class="printable-tab-group-header"
/>

<div
class="tab-pane active printable-tab-pane tab-pane-hide"
role="tabpanel"
>
<div
class="nav-tabs printable-tab-header"
>
<div
class="nav-link active"
/>
</div>

Some stuff about stars ...

<hr />
</div>

<div
class="tab-pane active printable-tab-pane tab-pane-hide"
role="tabpanel"
>
<div
class="nav-tabs printable-tab-header"
>
<div
class="nav-link active"
/>
</div>

<hr />
</div>
</div>

<div
class="printable-tab-group"
>
<div
class="printable-tab-group-header"
/>

<div
class="tab-pane active printable-tab-pane tab-pane-hide"
role="tabpanel"
>
<div
class="nav-tabs printable-tab-header"
>
<div
class="nav-link active"
/>
</div>

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla ullamcorper ultrices lobortis.

<hr />
</div>
</div>
</div>
</div>
`;

exports[`Tabset (Tabs) with Tab and Tab-Group Components renders tabset with tabs 1`] = `
<div
class="printable-tabs"
>
<ul
class="nav nav-tabs d-print-none nav-tabs"
role="tablist"
/>

<div
class="tab-content"
>
<div
class="tab-pane active printable-tab-pane tab-pane-hide"
role="tabpanel"
>
<div
class="nav-tabs printable-tab-header"
>
<div
class="nav-link active"
/>
</div>

Text in the first tab

<hr />
</div>

<div
class="tab-pane active printable-tab-pane tab-pane-hide"
role="tabpanel"
>
<div
class="nav-tabs printable-tab-header"
>
<div
class="nav-link active"
/>
</div>

Text in the second tab

<hr />
</div>
</div>
</div>
`;
Loading