From e3317ccffdd2e9abfd727ddaba2a5dfa05d63a59 Mon Sep 17 00:00:00 2001 From: Sarah Zhou Date: Thu, 7 Mar 2024 14:11:23 -0800 Subject: [PATCH] fix: allowing split view to have a custom aria label --- packages/split-view/src/SplitView.ts | 5 +-- packages/split-view/test/split-view.test.ts | 35 +++++++++++++++++++++ 2 files changed, 38 insertions(+), 2 deletions(-) diff --git a/packages/split-view/src/SplitView.ts b/packages/split-view/src/SplitView.ts index 04776578aed..c39805e557b 100644 --- a/packages/split-view/src/SplitView.ts +++ b/packages/split-view/src/SplitView.ts @@ -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` { 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( + html` + +
First panel
+
Second panel
+
+ ` + ); + 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( + html` + +
First panel
+
Second panel
+
+ ` + ); + 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(