mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-05-26 08:19:15 +08:00
fix(Tabs): should not render line when have no tab (#10063)
This commit is contained in:
parent
56b210156e
commit
f6a835721c
@ -121,27 +121,15 @@ exports[`should allow to set name prop 1`] = `
|
|||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`should emit rendered event after tab is rendered 1`] = `
|
exports[`should emit rendered event after tab is rendered 1`] = `
|
||||||
DOMWrapper {
|
<div id="van-tab"
|
||||||
"isDisabled": [Function],
|
|
||||||
"style": CSSStyleDeclaration {
|
|
||||||
"_importants": Object {},
|
|
||||||
"_length": 0,
|
|
||||||
"_onChange": [Function],
|
|
||||||
"_values": Object {},
|
|
||||||
},
|
|
||||||
"wrapperElement": <div
|
|
||||||
aria-labelledby="van-tabs-0"
|
|
||||||
class="van-tab__panel"
|
|
||||||
id="van-tab"
|
|
||||||
role="tabpanel"
|
role="tabpanel"
|
||||||
style=""
|
class="van-tab__panel"
|
||||||
tabindex="0"
|
tabindex="0"
|
||||||
>
|
aria-labelledby="van-tabs-0"
|
||||||
|
style
|
||||||
|
>
|
||||||
Text
|
Text
|
||||||
|
</div>
|
||||||
</div>,
|
|
||||||
}
|
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`should not render empty tab 1`] = `
|
exports[`should not render empty tab 1`] = `
|
||||||
|
@ -219,8 +219,6 @@ exports[`should render nav-bottom slot correctly 1`] = `
|
|||||||
class="van-tabs__nav van-tabs__nav--line"
|
class="van-tabs__nav van-tabs__nav--line"
|
||||||
aria-orientation="horizontal"
|
aria-orientation="horizontal"
|
||||||
>
|
>
|
||||||
<div class="van-tabs__line">
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
Nav Bottom
|
Nav Bottom
|
||||||
|
@ -256,7 +256,7 @@ test('should emit rendered event after tab is rendered', async () => {
|
|||||||
|
|
||||||
await later();
|
await later();
|
||||||
expect(onRendered).toHaveBeenCalledWith('a', 'title1');
|
expect(onRendered).toHaveBeenCalledWith('a', 'title1');
|
||||||
expect(wrapper.find('.van-tab__panel')).toMatchSnapshot();
|
expect(wrapper.find('.van-tab__panel').html()).toMatchSnapshot();
|
||||||
|
|
||||||
const tabs = wrapper.findAll('.van-tab');
|
const tabs = wrapper.findAll('.van-tab');
|
||||||
await tabs[1].trigger('click');
|
await tabs[1].trigger('click');
|
||||||
|
@ -384,6 +384,12 @@ export default defineComponent({
|
|||||||
/>
|
/>
|
||||||
));
|
));
|
||||||
|
|
||||||
|
const renderLine = () => {
|
||||||
|
if (props.type === 'line' && children.length) {
|
||||||
|
return <div class={bem('line')} style={state.lineStyle} />;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const renderHeader = () => {
|
const renderHeader = () => {
|
||||||
const { type, border } = props;
|
const { type, border } = props;
|
||||||
return (
|
return (
|
||||||
@ -403,9 +409,7 @@ export default defineComponent({
|
|||||||
>
|
>
|
||||||
{slots['nav-left']?.()}
|
{slots['nav-left']?.()}
|
||||||
{renderNav()}
|
{renderNav()}
|
||||||
{type === 'line' && (
|
{renderLine()}
|
||||||
<div class={bem('line')} style={state.lineStyle} />
|
|
||||||
)}
|
|
||||||
{slots['nav-right']?.()}
|
{slots['nav-right']?.()}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user