Skip to content

Commit ce1b894

Browse files
committed
only show headline if it has content. plus testing
1 parent 697a615 commit ce1b894

File tree

2 files changed

+20
-3
lines changed

2 files changed

+20
-3
lines changed

packages/uui-box/lib/uui-box.element.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,11 @@ export class UUIBoxElement extends LitElement {
7575
this.headline !== null
7676
? ''
7777
: 'display: none'}>
78-
<h5 id="headline">
78+
<h5
79+
id="headline"
80+
style=${this._headlineSlotHasContent || this.headline !== null
81+
? ''
82+
: 'display: none'}>
7983
${this.headline}
8084
<slot name="headline" @slotchange=${this._headlineSlotChanged}></slot>
8185
</h5>

packages/uui-box/lib/uui-box.test.ts

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@ import { UUIBoxElement } from './uui-box.element';
55
describe('UUIBox', () => {
66
let element: UUIBoxElement;
77
beforeEach(async () => {
8-
element = await fixture(html` <uui-box>
9-
<div slot="header">Header</div>
8+
element = await fixture(html` <uui-box headline="headline">
109
Main
1110
</uui-box>`);
1211
});
@@ -41,4 +40,18 @@ describe('UUIBox', () => {
4140
expect(slot).to.exist;
4241
});
4342
});
43+
44+
describe('UUIBox', () => {
45+
let element: UUIBoxElement;
46+
beforeEach(async () => {
47+
element = await fixture(html` <uui-box>
48+
<div slot="header">Something in the header</div>
49+
Main
50+
</uui-box>`);
51+
});
52+
53+
it('passes the a11y audit', async () => {
54+
await expect(element).shadowDom.to.be.accessible();
55+
});
56+
});
4457
});

0 commit comments

Comments
 (0)