From 7f29cc363007a3ef55c594b8a1fe8b7a084cc316 Mon Sep 17 00:00:00 2001 From: jantoun-scottlogic Date: Wed, 2 Oct 2024 16:17:47 +0100 Subject: [PATCH 01/17] Add only active tab to tab sequence --- src/app/tab/tabs/tabs.component.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/tab/tabs/tabs.component.html b/src/app/tab/tabs/tabs.component.html index 4f8e386..b437a45 100644 --- a/src/app/tab/tabs/tabs.component.html +++ b/src/app/tab/tabs/tabs.component.html @@ -5,7 +5,7 @@ [class.tce-active-tab]="tab.active()" (click)="selectTab(tab)" (keydown.enter)="selectTab(tab)" - tabindex="0" + [attr.tabindex]="tab.active() ? 0 : -1" class="tce-p-2 tce-cursor-pointer tce-border-b-2 tce-border-transparent hover:tce-border-slate-300"> {{ tab.title() }} From 7542d5a149933606154cdb68f3296e46aa7e200e Mon Sep 17 00:00:00 2001 From: jantoun-scottlogic Date: Wed, 2 Oct 2024 16:18:45 +0100 Subject: [PATCH 02/17] Use button element for tabs --- src/app/tab/tabs/tabs.component.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/app/tab/tabs/tabs.component.html b/src/app/tab/tabs/tabs.component.html index b437a45..f74faa3 100644 --- a/src/app/tab/tabs/tabs.component.html +++ b/src/app/tab/tabs/tabs.component.html @@ -1,6 +1,6 @@
@for (tab of tabs; track tab.title) { - + }
From 4f25d20c6f4694ca0afa2e7451f3febe3f9d5f54 Mon Sep 17 00:00:00 2001 From: jantoun-scottlogic Date: Wed, 2 Oct 2024 16:19:23 +0100 Subject: [PATCH 03/17] Remove enter key handler --- src/app/tab/tabs/tabs.component.html | 1 - 1 file changed, 1 deletion(-) diff --git a/src/app/tab/tabs/tabs.component.html b/src/app/tab/tabs/tabs.component.html index f74faa3..dbc8976 100644 --- a/src/app/tab/tabs/tabs.component.html +++ b/src/app/tab/tabs/tabs.component.html @@ -4,7 +4,6 @@ role="tab" [class.tce-active-tab]="tab.active()" (click)="selectTab(tab)" - (keydown.enter)="selectTab(tab)" [attr.tabindex]="tab.active() ? 0 : -1" class="tce-p-2 tce-cursor-pointer tce-border-b-2 tce-border-transparent hover:tce-border-slate-300"> {{ tab.title() }} From ab53330874f04edcccc564b8243df9a96dda1a1b Mon Sep 17 00:00:00 2001 From: jantoun-scottlogic Date: Wed, 2 Oct 2024 16:28:21 +0100 Subject: [PATCH 04/17] Add onKeydown event handler template --- src/app/tab/tabs/tabs.component.html | 1 + src/app/tab/tabs/tabs.component.ts | 23 +++++++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/src/app/tab/tabs/tabs.component.html b/src/app/tab/tabs/tabs.component.html index dbc8976..4f0028f 100644 --- a/src/app/tab/tabs/tabs.component.html +++ b/src/app/tab/tabs/tabs.component.html @@ -4,6 +4,7 @@ role="tab" [class.tce-active-tab]="tab.active()" (click)="selectTab(tab)" + (keydown)="onKeydown($event)" [attr.tabindex]="tab.active() ? 0 : -1" class="tce-p-2 tce-cursor-pointer tce-border-b-2 tce-border-transparent hover:tce-border-slate-300"> {{ tab.title() }} diff --git a/src/app/tab/tabs/tabs.component.ts b/src/app/tab/tabs/tabs.component.ts index 1c217dc..bbb73de 100644 --- a/src/app/tab/tabs/tabs.component.ts +++ b/src/app/tab/tabs/tabs.component.ts @@ -24,4 +24,27 @@ export class TabsComponent implements AfterContentInit { this.tabs.filter(tab => tab.active()).forEach(tab => tab.active.set(false)); selectedTab.active.set(true); } + + public onKeydown(event: KeyboardEvent) { + switch (event.key) { + case 'ArrowRight': + console.log('right'); + break; + + case 'ArrowLeft': + console.log('left'); + break; + + case 'Home': + console.log('home'); + break; + + case 'End': + console.log('end'); + break; + + default: + break; + } + } } From 44f87aa2f1748a68adc5ce1edf52b23652cc1345 Mon Sep 17 00:00:00 2001 From: jantoun-scottlogic Date: Thu, 3 Oct 2024 09:48:05 +0100 Subject: [PATCH 05/17] Implement right arrow key tab switching --- src/app/tab/tabs/tabs.component.html | 3 ++- src/app/tab/tabs/tabs.component.ts | 24 +++++++++++++++++++++--- 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/src/app/tab/tabs/tabs.component.html b/src/app/tab/tabs/tabs.component.html index 4f0028f..0d197bb 100644 --- a/src/app/tab/tabs/tabs.component.html +++ b/src/app/tab/tabs/tabs.component.html @@ -1,10 +1,11 @@
@for (tab of tabs; track tab.title) { From de3e4554a6f5b59f48a7c4a1cf19165711182227 Mon Sep 17 00:00:00 2001 From: jantoun-scottlogic Date: Thu, 3 Oct 2024 11:07:05 +0100 Subject: [PATCH 08/17] Add aria-live="off" to tabpanel Used so that the 'Diagram' and 'Table' tabs are announced by the screen reader when navigating with the 'left', 'right', 'home' and 'end' keys. --- src/app/tab/tabs/tabs.component.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/tab/tabs/tabs.component.html b/src/app/tab/tabs/tabs.component.html index 9560e67..89f861c 100644 --- a/src/app/tab/tabs/tabs.component.html +++ b/src/app/tab/tabs/tabs.component.html @@ -13,6 +13,6 @@ }
-
+
From 69f87af602bbb967bcb61e0d421ee0da4474512c Mon Sep 17 00:00:00 2001 From: jantoun-scottlogic Date: Thu, 3 Oct 2024 12:31:26 +0100 Subject: [PATCH 09/17] Add aria-controls and aria-labelledby --- src/app/tab/tab-item/tab-item.component.html | 9 +++++++-- src/app/tab/tabs/tabs.component.html | 12 ++++++------ 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/src/app/tab/tab-item/tab-item.component.html b/src/app/tab/tab-item/tab-item.component.html index 751f66c..46bed80 100644 --- a/src/app/tab/tab-item/tab-item.component.html +++ b/src/app/tab/tab-item/tab-item.component.html @@ -1,3 +1,8 @@ -@if (active()) { +
-} +
diff --git a/src/app/tab/tabs/tabs.component.html b/src/app/tab/tabs/tabs.component.html index 89f861c..5ef4ccc 100644 --- a/src/app/tab/tabs/tabs.component.html +++ b/src/app/tab/tabs/tabs.component.html @@ -1,18 +1,18 @@
- @for (tab of tabs; track tab.title) { + @for (tab of tabs; track tab.title()) { }
-
- -
+ From 0d66af4b5294081b6c2eb49b8519566844137181 Mon Sep 17 00:00:00 2001 From: jantoun-scottlogic Date: Thu, 3 Oct 2024 12:38:56 +0100 Subject: [PATCH 10/17] Fix assumptions and limitations tab screen reader announcement --- .../tech-carbon-estimator/tech-carbon-estimator.component.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/tech-carbon-estimator/tech-carbon-estimator.component.html b/src/app/tech-carbon-estimator/tech-carbon-estimator.component.html index c2db968..f1210c1 100644 --- a/src/app/tech-carbon-estimator/tech-carbon-estimator.component.html +++ b/src/app/tech-carbon-estimator/tech-carbon-estimator.component.html @@ -11,7 +11,7 @@

Technology Carbon Estimator

(formReset)="handleFormReset()"> - +
From d0eaed22c67b093fb180e1689540be8a6d31e587 Mon Sep 17 00:00:00 2001 From: jantoun-scottlogic Date: Thu, 3 Oct 2024 14:10:40 +0100 Subject: [PATCH 11/17] Update Playwright test --- playwright/tests/test_17_EstTool_UI_AssumpLimitations.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/playwright/tests/test_17_EstTool_UI_AssumpLimitations.py b/playwright/tests/test_17_EstTool_UI_AssumpLimitations.py index 138f3e2..25a1518 100644 --- a/playwright/tests/test_17_EstTool_UI_AssumpLimitations.py +++ b/playwright/tests/test_17_EstTool_UI_AssumpLimitations.py @@ -92,7 +92,7 @@ def test_example(page: Page) -> None: expect(page.get_by_text("Clearly there is a large")).to_be_visible() expect(page.get_by_text("The estimated kWh of cloud")).to_be_visible() expect(page.get_by_role("heading", name="Downstream Emissions")).to_be_visible() - expect(page.get_by_text("At present we focus on the")).to_be_visible() + expect(page.get_by_text("To do this we have collated")).to_be_visible() expect(page.get_by_role("cell", name="Type", exact=True)).to_be_visible() expect(page.get_by_text("These figures are combined")).to_be_visible() expect(page.get_by_role("heading", name="Network Data Transfer")).to_be_visible() From ff7238886d0d05ae1df1f617d714f5b9f221c858 Mon Sep 17 00:00:00 2001 From: jantoun-scottlogic Date: Thu, 3 Oct 2024 15:49:27 +0100 Subject: [PATCH 12/17] Update 'form shown by default' test' --- .../tech-carbon-estimator.component.spec.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/app/tech-carbon-estimator/tech-carbon-estimator.component.spec.ts b/src/app/tech-carbon-estimator/tech-carbon-estimator.component.spec.ts index 87b44cf..16a5965 100644 --- a/src/app/tech-carbon-estimator/tech-carbon-estimator.component.spec.ts +++ b/src/app/tech-carbon-estimator/tech-carbon-estimator.component.spec.ts @@ -54,8 +54,8 @@ describe('TechCarbonEstimatorComponent', () => { const formElement = fixture.nativeElement.querySelector('carbon-estimator-form'); const assumptionsElement = fixture.nativeElement.querySelector('assumptions-and-limitation'); - expect(formElement).toBeTruthy(); - expect(assumptionsElement).toBeFalsy(); + expect(formElement.checkVisibility()).toBeTrue(); + expect(assumptionsElement.checkVisibility()).toBeFalse(); }); it('should call estimationService.calculateCarbonEstimation when handleFormSubmit is called', () => { From eddf8ae7503cbf8a35b18b4819ff2418041a8892 Mon Sep 17 00:00:00 2001 From: jantoun-scottlogic Date: Thu, 3 Oct 2024 15:58:50 +0100 Subject: [PATCH 13/17] Update tab-item component test --- src/app/tab/tab-item/tab-item.component.spec.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/app/tab/tab-item/tab-item.component.spec.ts b/src/app/tab/tab-item/tab-item.component.spec.ts index 204f325..686860a 100644 --- a/src/app/tab/tab-item/tab-item.component.spec.ts +++ b/src/app/tab/tab-item/tab-item.component.spec.ts @@ -13,6 +13,7 @@ describe('TabItemComponent', () => { .compileComponents(); fixture = TestBed.createComponent(TabItemComponent); + fixture.componentRef.setInput('title', 'Tab Title'); component = fixture.componentInstance; fixture.detectChanges(); }); From ef084dcf086c161b8d14b419a8046f582b442d57 Mon Sep 17 00:00:00 2001 From: jantoun-scottlogic Date: Thu, 3 Oct 2024 16:21:57 +0100 Subject: [PATCH 14/17] Remove whitespace from ids --- src/app/tab/tab-item/tab-item.component.html | 4 ++-- src/app/tab/tabs/tabs.component.html | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/app/tab/tab-item/tab-item.component.html b/src/app/tab/tab-item/tab-item.component.html index 46bed80..ac830fd 100644 --- a/src/app/tab/tab-item/tab-item.component.html +++ b/src/app/tab/tab-item/tab-item.component.html @@ -2,7 +2,7 @@ role="tabpanel" aria-live="off" [hidden]="!active()" - [id]="title() + '-tabpanel'" - [attr.aria-labelledby]="title() + '-tab'"> + [id]="title().replaceAll(' ', '-') + '-tabpanel'" + [attr.aria-labelledby]="title().replaceAll(' ', '-') + '-tab'">
diff --git a/src/app/tab/tabs/tabs.component.html b/src/app/tab/tabs/tabs.component.html index 5ef4ccc..3c63d74 100644 --- a/src/app/tab/tabs/tabs.component.html +++ b/src/app/tab/tabs/tabs.component.html @@ -3,8 +3,8 @@