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
5 changes: 3 additions & 2 deletions packages/split-view/src/SplitView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,9 @@ export class SplitView extends SpectrumElement {
this.viewSize - this.splitterSize
)) as boolean,
};
const label =
this.label || (this.resizable ? 'Resize the panels' : undefined);
const label = this.resizable
? this.label || 'Resize the panels'
: undefined;

return html`
<slot
Expand Down
35 changes: 35 additions & 0 deletions packages/split-view/test/split-view.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -972,6 +972,41 @@ describe('SplitView', () => {
expect(testPanel).to.be.null;
});

it('allows a custom label when resizable if specified', async () => {
const customLabel = 'Resizable Split View Custom Label';
const defaultLabel = 'Resize the panels';
let el = await fixture<SplitView>(
html`
<sp-split-view
resizable
label=${customLabel}
primary-min="50"
secondary-min="50"
>
<div>First panel</div>
<div>Second panel</div>
</sp-split-view>
`
);
expect(el.label).to.equal(customLabel);
let splitter = el.shadowRoot.querySelector(
'#splitter'
) as HTMLDivElement;
expect(splitter.ariaLabel).to.equal(customLabel);

// If custom label not provided, should fall back to default label
el = await fixture<SplitView>(
html`
<sp-split-view resizable primary-min="50" secondary-min="50">
<div>First panel</div>
<div>Second panel</div>
</sp-split-view>
`
);
splitter = el.shadowRoot.querySelector('#splitter') as HTMLDivElement;
expect(splitter.ariaLabel).to.equal(defaultLabel);
});

it('keeps the splitter pos when removing and re-adding a panel', async () => {
let pointerId = -1;
const el = await fixture<SplitView>(
Expand Down