From 2172dbf8645e87cd2ded8ab5944e311bc954e354 Mon Sep 17 00:00:00 2001 From: MeganSitoy-Practera Date: Tue, 10 Nov 2026 15:59:44 +1100 Subject: [PATCH 1/4] WCAG minor fixes --- .../chat/chat-list/chat-list.component.html | 4 +- .../chat/chat-list/chat-list.component.ts | 13 ++++ .../chat/chat-room/chat-room.component.html | 3 +- .../chat/chat-room/chat-room.component.ts | 16 ++++- projects/v3/src/app/pages/chat/chat.page.ts | 19 +++++- projects/v3/src/app/pages/home/home.page.html | 63 ++++++++++--------- projects/v3/src/app/pages/home/home.page.scss | 7 +++ .../v3/src/app/pages/home/home.page.spec.ts | 9 +++ projects/v3/src/app/pages/home/home.page.ts | 61 +++++++++++++++++- .../personalised-header.component.html | 1 - 10 files changed, 157 insertions(+), 39 deletions(-) diff --git a/projects/v3/src/app/pages/chat/chat-list/chat-list.component.html b/projects/v3/src/app/pages/chat/chat-list/chat-list.component.html index 270edcecda..c76c50e093 100644 --- a/projects/v3/src/app/pages/chat/chat-list/chat-list.component.html +++ b/projects/v3/src/app/pages/chat/chat-list/chat-list.component.html @@ -24,14 +24,14 @@
+ [attr.aria-label]="'chatroom: ' + plainText(chat.name)">

@if ((chat.roles.length === 1) && (chat.roles.includes('mentor'))) { {{ utils.getUserRolesForUI('mentor') }} }
@if (chat.lastMessage) { -

+

} @else {

No messages.

} diff --git a/projects/v3/src/app/pages/chat/chat-list/chat-list.component.ts b/projects/v3/src/app/pages/chat/chat-list/chat-list.component.ts index ebbd6f29d3..5ddc81f640 100644 --- a/projects/v3/src/app/pages/chat/chat-list/chat-list.component.ts +++ b/projects/v3/src/app/pages/chat/chat-list/chat-list.component.ts @@ -148,4 +148,17 @@ export class ChatListComponent implements OnDestroy { return this.utils.timeFormatter(date); } + /** + * Accessible names must be text. Last messages and channel names are stored as HTML. + */ + plainText(value: string): string { + if (!value) { + return ''; + } + const withBreaks = value + .replace(//gi, ' ') + .replace(/<\/(p|div|li|h[1-6])>/gi, ' '); + return this.utils.decodeHtmlEntities(withBreaks).replace(/\s+/g, ' ').trim(); + } + } diff --git a/projects/v3/src/app/pages/chat/chat-room/chat-room.component.html b/projects/v3/src/app/pages/chat/chat-room/chat-room.component.html index ad72598ef9..7d9b53ec24 100644 --- a/projects/v3/src/app/pages/chat/chat-room/chat-room.component.html +++ b/projects/v3/src/app/pages/chat/chat-room/chat-room.component.html @@ -182,7 +182,7 @@ - diff --git a/projects/v3/src/app/pages/chat/chat-room/chat-room.component.ts b/projects/v3/src/app/pages/chat/chat-room/chat-room.component.ts index 379f4edb60..54b976b3d1 100644 --- a/projects/v3/src/app/pages/chat/chat-room/chat-room.component.ts +++ b/projects/v3/src/app/pages/chat/chat-room/chat-room.component.ts @@ -357,10 +357,14 @@ export class ChatRoomComponent implements OnInit, OnDestroy, AfterViewInit { // Set aria-labels for Quill toolbar elements (WCAG 4.1.2) setTimeout(() => { - this._setQuillToolbarAriaLabels(); + this.labelMessageEditor(); }, 500); } + labelMessageEditor(): void { + this._setQuillToolbarAriaLabels(); + } + /** * Set aria-labels for Quill editor toolbar elements for accessibility */ @@ -397,6 +401,16 @@ export class ChatRoomComponent implements OnInit, OnDestroy, AfterViewInit { if (videoInput && !videoInput.getAttribute('aria-label')) { videoInput.setAttribute('aria-label', 'Enter video embed URL'); } + + // Quill's contenteditable is not exposed as a named textbox unless these are set on .ql-editor. + const messageEditor = componentElement.querySelector('.ql-editor') as HTMLElement; + if (messageEditor) { + messageEditor.setAttribute('role', 'textbox'); + messageEditor.setAttribute('aria-multiline', 'true'); + if (!messageEditor.getAttribute('aria-label')) { + messageEditor.setAttribute('aria-label', $localize`Enter your message`); + } + } } /** diff --git a/projects/v3/src/app/pages/chat/chat.page.ts b/projects/v3/src/app/pages/chat/chat.page.ts index 919aa565e5..5481a1d051 100644 --- a/projects/v3/src/app/pages/chat/chat.page.ts +++ b/projects/v3/src/app/pages/chat/chat.page.ts @@ -1,7 +1,22 @@ -import { Component } from '@angular/core'; +import { Component, OnInit } from '@angular/core'; +import { UtilsService } from '@v3/services/utils.service'; @Component({ standalone: false, template: '', }) -export class ChatPage {} +export class ChatPage implements OnInit { + constructor(private utils: UtilsService) {} + + ngOnInit() { + this.setMessagesTitle(); + } + + ionViewDidEnter() { + this.setMessagesTitle(); + } + + private setMessagesTitle() { + this.utils.setPageTitle('Messages - Practera'); + } +} diff --git a/projects/v3/src/app/pages/home/home.page.html b/projects/v3/src/app/pages/home/home.page.html index 2e5c0af65a..b178e026c7 100644 --- a/projects/v3/src/app/pages/home/home.page.html +++ b/projects/v3/src/app/pages/home/home.page.html @@ -134,25 +134,22 @@ [value]="display" role="tablist" aria-label="Content navigation tabs" i18n-aria-label> - Activities - { getIsPointsConfigured, select, true {Badges & Points} false {Badges} } @if (pulseCheckIndicatorEnabled === true && !isExpertWithoutTeam) { - Skill & Progress Surveys @@ -190,14 +187,15 @@ i18n>Activity list
- @if (activitySearchText && filteredMilestones) { @@ -219,27 +217,30 @@ i18n-aria-label> @if ((activitySearchText ? filteredMilestones : milestones)?.length > 0) { @for (milestone of (activitySearchText ? filteredMilestones : milestones)!; track milestone) { - -
- @if (milestone.isLocked) { - - } -
+

+ +
+ @if (milestone.isLocked) { + + } +
+

@if (milestone?.description) { - diff --git a/projects/v3/src/app/pages/home/home.page.scss b/projects/v3/src/app/pages/home/home.page.scss index bbe4bac59e..b160d48d9b 100644 --- a/projects/v3/src/app/pages/home/home.page.scss +++ b/projects/v3/src/app/pages/home/home.page.scss @@ -1,3 +1,10 @@ +.milestone-heading { + margin: 0; + font-size: inherit; + font-weight: inherit; + line-height: inherit; +} + .milestone-name { &.locked { cursor: pointer; diff --git a/projects/v3/src/app/pages/home/home.page.spec.ts b/projects/v3/src/app/pages/home/home.page.spec.ts index 81cf18c884..a2598ffd5b 100644 --- a/projects/v3/src/app/pages/home/home.page.spec.ts +++ b/projects/v3/src/app/pages/home/home.page.spec.ts @@ -399,16 +399,25 @@ describe('HomePage', () => { }); it('should set page title with experience name', async () => { + (TestBed.inject(Router) as unknown as { url: string }).url = '/v3/home'; await component.updateDashboard(); expect(utilsService.setPageTitle).toHaveBeenCalledWith('Test Experience'); }); it('should set page title with default when experience has no name', async () => { + (TestBed.inject(Router) as unknown as { url: string }).url = '/v3/home'; storageService.get.and.returnValue({}); await component.updateDashboard(); expect(utilsService.setPageTitle).toHaveBeenCalledWith('Practera'); }); + it('should not replace another page title when the dashboard refreshes off Home', async () => { + (TestBed.inject(Router) as unknown as { url: string }).url = '/v3/messages'; + utilsService.setPageTitle.calls.reset(); + await component.updateDashboard(); + expect(utilsService.setPageTitle).not.toHaveBeenCalled(); + }); + it('should set default lead image from experience card URL', async () => { await component.updateDashboard(); expect(component.defaultLeadImage).toBe('test-url'); diff --git a/projects/v3/src/app/pages/home/home.page.ts b/projects/v3/src/app/pages/home/home.page.ts index afa84e078f..026bd5dd0f 100644 --- a/projects/v3/src/app/pages/home/home.page.ts +++ b/projects/v3/src/app/pages/home/home.page.ts @@ -65,6 +65,7 @@ export class HomePage implements OnInit, OnDestroy, AfterViewChecked { @ViewChild('activityCol') activityCol: { el: HTMLIonColElement }; @ViewChild('activities', { static: false }) activities!: ElementRef; + @ViewChild('activityFilter') activityFilter?: { getInputElement?: () => Promise }; pulseCheckSkills: PulseCheckSkill[] = []; // project brief data from team storage @@ -74,6 +75,7 @@ export class HomePage implements OnInit, OnDestroy, AfterViewChecked { // activity search/filter activitySearchText = ''; filteredMilestones: Milestone[] | null = null; + private activityFilterLabelRequested = false; // Expose Math to template Math = Math; @@ -110,6 +112,60 @@ export class HomePage implements OnInit, OnDestroy, AfterViewChecked { if (this.activities && this.isElementVisible(this.activities.nativeElement) && id !== null && this.milestones?.length > 0) { this.scrollToElement(id); } + + this.labelActivityFilter(); + this.linkContentTabs(); + } + + private isHomeUrl(): boolean { + const path = (this.router.url || '').split('?')[0].split('#')[0]; + return path.endsWith('/home'); + } + + /** + * Ionic's searchbar names its inner input "search text" and does not use the host aria-label. + * Point that input at the visible placeholder. + */ + private labelActivityFilter(): void { + if (!this.activityFilter?.getInputElement) { + this.activityFilterLabelRequested = false; + return; + } + if (this.activityFilterLabelRequested) { + return; + } + this.activityFilterLabelRequested = true; + this.activityFilter.getInputElement().then((input) => { + if (!input) { + this.activityFilterLabelRequested = false; + return; + } + input.setAttribute('aria-label', $localize`Filter by activity title or description`); + }).catch(() => { + this.activityFilterLabelRequested = false; + }); + } + + /** + * ion-segment-button already exposes an inner tab. Copy the panel relationship onto that tab. + * The host id stays in light DOM so the tab panel aria-labelledby can still find it. + */ + private linkContentTabs(): void { + const host = this.activityCol?.el; + if (!host) { + return; + } + host.querySelectorAll('ion-segment-button').forEach((button: Element) => { + const segmentButton = button as HTMLElement; + const native = segmentButton.shadowRoot?.querySelector('button'); + if (!native) { + return; + } + const controls = segmentButton.getAttribute('aria-controls'); + if (controls && native.getAttribute('aria-controls') !== controls) { + native.setAttribute('aria-controls', controls); + } + }); } ngOnInit() { @@ -285,7 +341,10 @@ export class HomePage implements OnInit, OnDestroy, AfterViewChecked { }); } - this.utils.setPageTitle(this.experience?.name || 'Practera'); + // Home stays mounted and can refresh after other navigations. Only retitle while Home is current. + if (this.isHomeUrl()) { + this.utils.setPageTitle(this.experience?.name || 'Practera'); + } this.defaultLeadImage = this.experience.cardUrl || 'assets/default-experience-image.svg'; // reset & load bookmarks diff --git a/projects/v3/src/app/personalised-header/personalised-header.component.html b/projects/v3/src/app/personalised-header/personalised-header.component.html index f0b5c99db3..a19fc700ad 100644 --- a/projects/v3/src/app/personalised-header/personalised-header.component.html +++ b/projects/v3/src/app/personalised-header/personalised-header.component.html @@ -8,7 +8,6 @@ class="support-btn" shape="round" size="small" - aria-label="Get help and support" i18n-aria-label i18n> Do you need help? From a3bf5062f37cb09ea1163c95a4d1ee450cac7fb8 Mon Sep 17 00:00:00 2001 From: chaw Date: Wed, 11 Nov 2026 12:28:01 +0800 Subject: [PATCH 2/4] fix: harden chat labels and home tab accessibility --- .../chat-list/chat-list.component.spec.ts | 23 +++++++ .../chat/chat-list/chat-list.component.ts | 11 +++- .../chat/chat-room/chat-room.component.html | 4 +- .../chat-room/chat-room.component.spec.ts | 12 ++++ .../chat/chat-room/chat-room.component.ts | 18 ++--- projects/v3/src/app/pages/home/home.page.html | 66 +++++++++---------- projects/v3/src/app/pages/home/home.page.scss | 38 ++++++++--- .../v3/src/app/pages/home/home.page.spec.ts | 48 ++++++++++++++ projects/v3/src/app/pages/home/home.page.ts | 51 +++++++------- 9 files changed, 183 insertions(+), 88 deletions(-) diff --git a/projects/v3/src/app/pages/chat/chat-list/chat-list.component.spec.ts b/projects/v3/src/app/pages/chat/chat-list/chat-list.component.spec.ts index 2b0f033673..bc4e35347c 100644 --- a/projects/v3/src/app/pages/chat/chat-list/chat-list.component.spec.ts +++ b/projects/v3/src/app/pages/chat/chat-list/chat-list.component.spec.ts @@ -190,4 +190,27 @@ describe('ChatListComponent', () => { }); }); + describe('accessible chat text', () => { + beforeEach(() => { + (utils.decodeHtmlEntities as jasmine.Spy).and.callFake((value: string) => + UtilsService.prototype.decodeHtmlEntities.call({ document }, value)); + }); + + it('decodes entities and separates HTML blocks', () => { + expect(component.plainText('

A & B

Next
line
')).toBe('A & B Next line'); + expect(component.plainText('')).toBe(''); + }); + + it('keeps HTML event handlers inert when extracting a message label', async () => { + const marker = '__pr2808MessageExecuted'; + (window as any)[marker] = false; + try { + expect(component.plainText(`

Hello

`)).toBe('Hello'); + await new Promise(resolve => setTimeout(resolve, 100)); + expect((window as any)[marker]).toBeFalse(); + } finally { + delete (window as any)[marker]; + } + }); + }); }); diff --git a/projects/v3/src/app/pages/chat/chat-list/chat-list.component.ts b/projects/v3/src/app/pages/chat/chat-list/chat-list.component.ts index 5ddc81f640..2fe55e3d18 100644 --- a/projects/v3/src/app/pages/chat/chat-list/chat-list.component.ts +++ b/projects/v3/src/app/pages/chat/chat-list/chat-list.component.ts @@ -1,4 +1,5 @@ -import { ChangeDetectorRef, Component, Output, EventEmitter, NgZone, Input, OnDestroy } from '@angular/core'; +import { DOCUMENT } from '@angular/common'; +import { Inject, ChangeDetectorRef, Component, Output, EventEmitter, NgZone, Input, OnDestroy } from '@angular/core'; import { Router, NavigationExtras } from '@angular/router'; import { BrowserStorageService } from '@v3/services/storage.service'; import { UtilsService } from '@v3/services/utils.service'; @@ -32,7 +33,8 @@ export class ChatListComponent implements OnDestroy { private storage: BrowserStorageService, private ngZone: NgZone, private cdr: ChangeDetectorRef, - private pusherService: PusherService + private pusherService: PusherService, + @Inject(DOCUMENT) private document: Document ) { this.isMobile = this.utils.isMobile(); this.utils.getEvent('chat:new-message') @@ -158,7 +160,10 @@ export class ChatListComponent implements OnDestroy { const withBreaks = value .replace(//gi, ' ') .replace(/<\/(p|div|li|h[1-6])>/gi, ' '); - return this.utils.decodeHtmlEntities(withBreaks).replace(/\s+/g, ' ').trim(); + // Template contents are inert: message images and event handlers never activate. + const template = this.document.createElement('template'); + template.innerHTML = withBreaks; + return (template.content.textContent || '').replace(/\s+/g, ' ').trim(); } } diff --git a/projects/v3/src/app/pages/chat/chat-room/chat-room.component.html b/projects/v3/src/app/pages/chat/chat-room/chat-room.component.html index 7d9b53ec24..47b66dd165 100644 --- a/projects/v3/src/app/pages/chat/chat-room/chat-room.component.html +++ b/projects/v3/src/app/pages/chat/chat-room/chat-room.component.html @@ -182,7 +182,7 @@ - diff --git a/projects/v3/src/app/pages/chat/chat-room/chat-room.component.spec.ts b/projects/v3/src/app/pages/chat/chat-room/chat-room.component.spec.ts index 3d36ff9ee7..454ae28fce 100644 --- a/projects/v3/src/app/pages/chat/chat-room/chat-room.component.spec.ts +++ b/projects/v3/src/app/pages/chat/chat-room/chat-room.component.spec.ts @@ -791,4 +791,16 @@ describe('ChatRoomComponent', () => { }); }); + it('labels the created editable root rather than a message preview', () => { + const preview = document.createElement('div'); + preview.className = 'ql-editor'; + fixture.nativeElement.prepend(preview); + const root = document.createElement('div'); + root.contentEditable = 'true'; + (component.labelMessageEditor as any)({ root }); + expect(root.getAttribute('role')).toBe('textbox'); + expect(root.getAttribute('aria-multiline')).toBe('true'); + expect(root.getAttribute('aria-label')).toBe('Enter your message'); + expect(preview.hasAttribute('role')).toBeFalse(); + }); }); diff --git a/projects/v3/src/app/pages/chat/chat-room/chat-room.component.ts b/projects/v3/src/app/pages/chat/chat-room/chat-room.component.ts index 54b976b3d1..d41dee0df6 100644 --- a/projects/v3/src/app/pages/chat/chat-room/chat-room.component.ts +++ b/projects/v3/src/app/pages/chat/chat-room/chat-room.component.ts @@ -14,6 +14,7 @@ import { EditMessagePopupComponent } from '../edit-message-popup/edit-message-po import { Subject, Subscription, timer } from 'rxjs'; import { debounceTime, switchMap, takeUntil, tap } from 'rxjs/operators'; import { QuillModules } from 'ngx-quill'; +import type Quill from 'quill'; import { UppyFileData, UppyUploaderResponse, UppyUploaderService } from '../../../components/uppy-uploader/uppy-uploader.service'; enum ScrollPosition { @@ -357,11 +358,14 @@ export class ChatRoomComponent implements OnInit, OnDestroy, AfterViewInit { // Set aria-labels for Quill toolbar elements (WCAG 4.1.2) setTimeout(() => { - this.labelMessageEditor(); + this._setQuillToolbarAriaLabels(); }, 500); } - labelMessageEditor(): void { + labelMessageEditor(editor: Quill): void { + editor.root.setAttribute('role', 'textbox'); + editor.root.setAttribute('aria-multiline', 'true'); + editor.root.setAttribute('aria-label', $localize`Enter your message`); this._setQuillToolbarAriaLabels(); } @@ -401,16 +405,6 @@ export class ChatRoomComponent implements OnInit, OnDestroy, AfterViewInit { if (videoInput && !videoInput.getAttribute('aria-label')) { videoInput.setAttribute('aria-label', 'Enter video embed URL'); } - - // Quill's contenteditable is not exposed as a named textbox unless these are set on .ql-editor. - const messageEditor = componentElement.querySelector('.ql-editor') as HTMLElement; - if (messageEditor) { - messageEditor.setAttribute('role', 'textbox'); - messageEditor.setAttribute('aria-multiline', 'true'); - if (!messageEditor.getAttribute('aria-label')) { - messageEditor.setAttribute('aria-label', $localize`Enter your message`); - } - } } /** diff --git a/projects/v3/src/app/pages/home/home.page.html b/projects/v3/src/app/pages/home/home.page.html index b178e026c7..6f2207c95b 100644 --- a/projects/v3/src/app/pages/home/home.page.html +++ b/projects/v3/src/app/pages/home/home.page.html @@ -130,49 +130,47 @@ [ngClass]="{'mobile': isMobile}">

Activities

- - - Activities - - - { getIsPointsConfigured, select, true {Badges & Points} false {Badges} } - + + @if (pulseCheckIndicatorEnabled === true && !isExpertWithoutTeam) { - - Skill & Progress Surveys - + } - +
- @switch (display) { - @case ('activities') { -
- -
+
+ @if (display === 'activities') { + } - @case ('badges') { -
- -
+
+
+ @if (display === 'badges') { + } - @case ('pulse-checks') { -
+
+ @if (pulseCheckIndicatorEnabled === true && !isExpertWithoutTeam) { +
+ @if (display === 'pulse-checks') { -
- } + } +
} +
diff --git a/projects/v3/src/app/pages/home/home.page.scss b/projects/v3/src/app/pages/home/home.page.scss index b160d48d9b..d9eed31253 100644 --- a/projects/v3/src/app/pages/home/home.page.scss +++ b/projects/v3/src/app/pages/home/home.page.scss @@ -14,17 +14,39 @@ } } -ion-segment-button.ion-focused { - border: 1px solid var(--ion-color-primary); -} img { width: 100%; } -ion-segment { - --background: var(--ion-color-light); +.content-tabs { + display: flex; + gap: 2px; padding: 10px; - z-index: 1; + background: var(--ion-color-light); + + button { + flex: 1; + min-width: 0; + padding: 8px 4px; + border: 0; + border-radius: 7px; + background: transparent; + color: var(--ion-text-color); + font: inherit; + font-size: 14px; + cursor: pointer; + + &[aria-selected='true'] { + background: var(--ion-background-color); + box-shadow: 0 2px 5px rgb(0 0 0 / 12%); + } + + &:focus-visible { + outline: 2px solid var(--ion-color-primary); + outline-offset: 2px; + } + } } + .milestone-name { --color: var(--ion-color-primary); --background: var(--ion-color-primary-tint); @@ -40,10 +62,6 @@ ion-segment { border-left: 1px solid var(--practera-grey-25); padding: 0 18px; - ion-segment { - border-radius: 0; - } - &.mobile { border-left: none; padding: 0; diff --git a/projects/v3/src/app/pages/home/home.page.spec.ts b/projects/v3/src/app/pages/home/home.page.spec.ts index a2598ffd5b..bdd2daeb7a 100644 --- a/projects/v3/src/app/pages/home/home.page.spec.ts +++ b/projects/v3/src/app/pages/home/home.page.spec.ts @@ -487,4 +487,52 @@ describe('HomePage', () => { }); }); + describe('content tab accessibility', () => { + beforeEach(() => { + component.achievements = []; + fixture.changeDetectorRef.markForCheck(); + }); + it('links focusable tabs and their panels within the same DOM', () => { + const tabs: HTMLElement[] = Array.from(fixture.nativeElement.querySelectorAll('button[role="tab"]')); + expect(tabs.length).toBe(2); + tabs.forEach(tab => { + const panel = fixture.nativeElement.querySelector('#' + tab.getAttribute('aria-controls')); + expect(panel).not.toBeNull(); + expect(panel?.getRootNode()).toBe(tab.getRootNode()); + expect(panel?.getAttribute('aria-labelledby')).toBe(tab.id); + }); + }); + + it('moves focus and selection with arrows, wrapping across available tabs', () => { + const tabs: HTMLButtonElement[] = Array.from(fixture.nativeElement.querySelectorAll('button[role="tab"]')); + expect(tabs.length).toBe(2); + if (tabs.length !== 2) { return; } + tabs[0].dispatchEvent(new KeyboardEvent('keydown', { key: 'ArrowRight', bubbles: true, cancelable: true })); + fixture.detectChanges(); + expect(component.display).toBe('badges'); + expect(document.activeElement).toBe(tabs[1]); + expect(tabs[1].getAttribute('aria-selected')).toBe('true'); + expect(tabs[1].tabIndex).toBe(0); + expect(tabs[0].tabIndex).toBe(-1); + tabs[1].dispatchEvent(new KeyboardEvent('keydown', { key: 'ArrowRight', bubbles: true, cancelable: true })); + fixture.detectChanges(); + expect(component.display).toBe('activities'); + }); + + it('includes the survey tab and supports Home and End keys', () => { + component.pulseCheckIndicatorEnabled = true; + component.isExpertWithoutTeam = false; + fixture.changeDetectorRef.markForCheck(); + fixture.detectChanges(); + const tabs: HTMLButtonElement[] = Array.from(fixture.nativeElement.querySelectorAll('button[role="tab"]')); + expect(tabs.length).toBe(3); + if (tabs.length !== 3) { return; } + tabs[0].dispatchEvent(new KeyboardEvent('keydown', { key: 'End', bubbles: true, cancelable: true })); + fixture.detectChanges(); + expect(component.display).toBe('pulse-checks'); + tabs[2].dispatchEvent(new KeyboardEvent('keydown', { key: 'Home', bubbles: true, cancelable: true })); + fixture.detectChanges(); + expect(component.display).toBe('activities'); + }); + }); }); diff --git a/projects/v3/src/app/pages/home/home.page.ts b/projects/v3/src/app/pages/home/home.page.ts index 026bd5dd0f..76a1bcd7f6 100644 --- a/projects/v3/src/app/pages/home/home.page.ts +++ b/projects/v3/src/app/pages/home/home.page.ts @@ -114,7 +114,6 @@ export class HomePage implements OnInit, OnDestroy, AfterViewChecked { } this.labelActivityFilter(); - this.linkContentTabs(); } private isHomeUrl(): boolean { @@ -135,7 +134,7 @@ export class HomePage implements OnInit, OnDestroy, AfterViewChecked { return; } this.activityFilterLabelRequested = true; - this.activityFilter.getInputElement().then((input) => { + Promise.resolve().then(() => this.activityFilter?.getInputElement?.()).then((input) => { if (!input) { this.activityFilterLabelRequested = false; return; @@ -146,28 +145,6 @@ export class HomePage implements OnInit, OnDestroy, AfterViewChecked { }); } - /** - * ion-segment-button already exposes an inner tab. Copy the panel relationship onto that tab. - * The host id stays in light DOM so the tab panel aria-labelledby can still find it. - */ - private linkContentTabs(): void { - const host = this.activityCol?.el; - if (!host) { - return; - } - host.querySelectorAll('ion-segment-button').forEach((button: Element) => { - const segmentButton = button as HTMLElement; - const native = segmentButton.shadowRoot?.querySelector('button'); - if (!native) { - return; - } - const controls = segmentButton.getAttribute('aria-controls'); - if (controls && native.getAttribute('aria-controls') !== controls) { - native.setAttribute('aria-controls', controls); - } - }); - } - ngOnInit() { this.updateUserRoleState(); this.pulseCheckIndicatorEnabled = this.storageService.getFeature('pulseCheckIndicator'); @@ -387,13 +364,33 @@ export class HomePage implements OnInit, OnDestroy, AfterViewChecked { this.isExpertWithoutTeam = this.isExpert && !teamId; } - switchContent(event) { + switchContent(value: string) { // update points upon switching to badges tab - if (event.detail.value === "badges") { + if (value === 'badges') { this.getIsPointsConfigured = this.achievementService.isPointsConfigured; this.getEarnedPoints = this.achievementService.earnedPoints; } - this.display = event.detail.value; + this.display = value; + } + + navigateContentTabs(event: KeyboardEvent): void { + const current = event.target as HTMLElement; + const tabs = Array.from(current.closest('[role="tablist"]')?.querySelectorAll('[role="tab"]') || []); + const index = tabs.indexOf(current as HTMLButtonElement); + if (index < 0) { + return; + } + let next: number; + switch (event.key) { + case 'ArrowRight': next = (index + 1) % tabs.length; break; + case 'ArrowLeft': next = (index + tabs.length - 1) % tabs.length; break; + case 'Home': next = 0; break; + case 'End': next = tabs.length - 1; break; + default: return; + } + event.preventDefault(); + tabs[next].click(); + tabs[next].focus(); } endingIcon(activity) { From 1f55ac29c1b62f8a3c90fe8e8ff7ffb3f8e62ecb Mon Sep 17 00:00:00 2001 From: chaw Date: Wed, 11 Nov 2026 12:40:06 +0800 Subject: [PATCH 3/4] fix: preserve Ionic segment design for accessible tabs --- projects/v3/src/app/pages/home/home.page.html | 39 ++++--- projects/v3/src/app/pages/home/home.page.scss | 38 ++----- .../v3/src/app/pages/home/home.page.spec.ts | 105 ++++++++++++------ projects/v3/src/app/pages/home/home.page.ts | 62 +++++++---- 4 files changed, 140 insertions(+), 104 deletions(-) diff --git a/projects/v3/src/app/pages/home/home.page.html b/projects/v3/src/app/pages/home/home.page.html index 6f2207c95b..e21f86a12a 100644 --- a/projects/v3/src/app/pages/home/home.page.html +++ b/projects/v3/src/app/pages/home/home.page.html @@ -130,28 +130,31 @@ [ngClass]="{'mobile': isMobile}">

Activities

-
- - + + Activities + + + { getIsPointsConfigured, select, true {Badges & Points} false {Badges} } + @if (pulseCheckIndicatorEnabled === true && !isExpertWithoutTeam) { - + + Skill & Progress Surveys + } -
+
@if (display === 'activities') { diff --git a/projects/v3/src/app/pages/home/home.page.scss b/projects/v3/src/app/pages/home/home.page.scss index d9eed31253..b160d48d9b 100644 --- a/projects/v3/src/app/pages/home/home.page.scss +++ b/projects/v3/src/app/pages/home/home.page.scss @@ -14,39 +14,17 @@ } } +ion-segment-button.ion-focused { + border: 1px solid var(--ion-color-primary); +} img { width: 100%; } -.content-tabs { - display: flex; - gap: 2px; +ion-segment { + --background: var(--ion-color-light); padding: 10px; - background: var(--ion-color-light); - - button { - flex: 1; - min-width: 0; - padding: 8px 4px; - border: 0; - border-radius: 7px; - background: transparent; - color: var(--ion-text-color); - font: inherit; - font-size: 14px; - cursor: pointer; - - &[aria-selected='true'] { - background: var(--ion-background-color); - box-shadow: 0 2px 5px rgb(0 0 0 / 12%); - } - - &:focus-visible { - outline: 2px solid var(--ion-color-primary); - outline-offset: 2px; - } - } + z-index: 1; } - .milestone-name { --color: var(--ion-color-primary); --background: var(--ion-color-primary-tint); @@ -62,6 +40,10 @@ img { border-left: 1px solid var(--practera-grey-25); padding: 0 18px; + ion-segment { + border-radius: 0; + } + &.mobile { border-left: none; padding: 0; diff --git a/projects/v3/src/app/pages/home/home.page.spec.ts b/projects/v3/src/app/pages/home/home.page.spec.ts index bdd2daeb7a..51dde0b2d2 100644 --- a/projects/v3/src/app/pages/home/home.page.spec.ts +++ b/projects/v3/src/app/pages/home/home.page.spec.ts @@ -487,52 +487,87 @@ describe('HomePage', () => { }); }); - describe('content tab accessibility', () => { - beforeEach(() => { - component.achievements = []; - fixture.changeDetectorRef.markForCheck(); - }); - it('links focusable tabs and their panels within the same DOM', () => { - const tabs: HTMLElement[] = Array.from(fixture.nativeElement.querySelectorAll('button[role="tab"]')); + describe('Ionic content tab accessibility', () => { + it('keeps Ionic segment controls and light DOM panel labels', () => { + const segment = fixture.nativeElement.querySelector('ion-segment'); + expect(segment).not.toBeNull(); + const tabs: HTMLElement[] = Array.from(fixture.nativeElement.querySelectorAll('ion-segment-button')); expect(tabs.length).toBe(2); tabs.forEach(tab => { const panel = fixture.nativeElement.querySelector('#' + tab.getAttribute('aria-controls')); expect(panel).not.toBeNull(); - expect(panel?.getRootNode()).toBe(tab.getRootNode()); expect(panel?.getAttribute('aria-labelledby')).toBe(tab.id); }); + expect(fixture.nativeElement.querySelector('.content-tabs')).toBeNull(); }); - it('moves focus and selection with arrows, wrapping across available tabs', () => { - const tabs: HTMLButtonElement[] = Array.from(fixture.nativeElement.querySelectorAll('button[role="tab"]')); - expect(tabs.length).toBe(2); - if (tabs.length !== 2) { return; } - tabs[0].dispatchEvent(new KeyboardEvent('keydown', { key: 'ArrowRight', bubbles: true, cancelable: true })); + it('switches content through Ionic ionChange and refreshes badge points', () => { + const segment = fixture.nativeElement.querySelector('ion-segment'); + expect(segment).not.toBeNull(); + if (!segment) { return; } + component.achievements = []; + (achievementService as any).isPointsConfigured = true; + (achievementService as any).earnedPoints = 12; + segment.dispatchEvent(new CustomEvent('ionChange', { detail: { value: 'badges' } })); fixture.detectChanges(); expect(component.display).toBe('badges'); - expect(document.activeElement).toBe(tabs[1]); - expect(tabs[1].getAttribute('aria-selected')).toBe('true'); - expect(tabs[1].tabIndex).toBe(0); - expect(tabs[0].tabIndex).toBe(-1); - tabs[1].dispatchEvent(new KeyboardEvent('keydown', { key: 'ArrowRight', bubbles: true, cancelable: true })); - fixture.detectChanges(); - expect(component.display).toBe('activities'); - }); + expect(component.getEarnedPoints).toBe(12); + expect(component.getIsPointsConfigured).toBeTrue(); + expect(fixture.nativeElement.querySelector('#badges-panel').hidden).toBeFalse(); + expect(fixture.nativeElement.querySelector('#activities-panel').hidden).toBeTrue(); + }); + + describe('shadow DOM panel references', () => { + let host: HTMLIonColElement; + let tab: HTMLElement; + let native: HTMLButtonElement; + let panel: HTMLElement; + + beforeEach(() => { + host = document.createElement('ion-col'); + tab = document.createElement('ion-segment-button'); + tab.setAttribute('aria-controls', 'review-panel'); + native = document.createElement('button'); + (tab.shadowRoot || tab.attachShadow({ mode: 'open' })).append(native); + panel = document.createElement('div'); + panel.id = 'review-panel'; + host.append(tab, panel); + document.body.append(host); + component.activityCol = { el: host }; + }); - it('includes the survey tab and supports Home and End keys', () => { - component.pulseCheckIndicatorEnabled = true; - component.isExpertWithoutTeam = false; - fixture.changeDetectorRef.markForCheck(); - fixture.detectChanges(); - const tabs: HTMLButtonElement[] = Array.from(fixture.nativeElement.querySelectorAll('button[role="tab"]')); - expect(tabs.length).toBe(3); - if (tabs.length !== 3) { return; } - tabs[0].dispatchEvent(new KeyboardEvent('keydown', { key: 'End', bubbles: true, cancelable: true })); - fixture.detectChanges(); - expect(component.display).toBe('pulse-checks'); - tabs[2].dispatchEvent(new KeyboardEvent('keydown', { key: 'Home', bubbles: true, cancelable: true })); - fixture.detectChanges(); - expect(component.display).toBe('activities'); + afterEach(() => host.remove()); + + it('links the inner Ionic button to its light DOM panel by element reference', () => { + (component as any).linkContentTabs?.(); + expect(Array.from(native.ariaControlsElements || [])).toEqual([panel]); + expect(native.getAttribute('aria-controls')).not.toBe('review-panel'); + }); + + it('waits for Ionic hydration before linking a newly created button', async () => { + native.remove(); + (tab as any).componentOnReady = () => Promise.resolve().then(() => { + tab.shadowRoot!.append(native); + return tab; + }); + (component as any).linkContentTabs?.(); + await Promise.resolve(); + await Promise.resolve(); + expect(Array.from(native.ariaControlsElements || [])).toEqual([panel]); + }); + + it('keeps older browsers free of invalid shadow DOM ID references', () => { + const descriptor = Object.getOwnPropertyDescriptor(Element.prototype, 'ariaControlsElements')!; + Reflect.deleteProperty(Element.prototype, 'ariaControlsElements'); + try { + (component as any).linkContentTabs?.(); + expect(native.hasAttribute('aria-controls')).toBeFalse(); + expect(Object.hasOwn(native, 'ariaControlsElements')).toBeFalse(); + expect(tab.getAttribute('aria-controls')).toBe('review-panel'); + } finally { + Object.defineProperty(Element.prototype, 'ariaControlsElements', descriptor); + } + }); }); }); }); diff --git a/projects/v3/src/app/pages/home/home.page.ts b/projects/v3/src/app/pages/home/home.page.ts index 76a1bcd7f6..abe8fafa10 100644 --- a/projects/v3/src/app/pages/home/home.page.ts +++ b/projects/v3/src/app/pages/home/home.page.ts @@ -76,6 +76,7 @@ export class HomePage implements OnInit, OnDestroy, AfterViewChecked { activitySearchText = ''; filteredMilestones: Milestone[] | null = null; private activityFilterLabelRequested = false; + private pendingContentTabs = new WeakSet(); // Expose Math to template Math = Math; @@ -114,6 +115,7 @@ export class HomePage implements OnInit, OnDestroy, AfterViewChecked { } this.labelActivityFilter(); + this.linkContentTabs(); } private isHomeUrl(): boolean { @@ -145,6 +147,40 @@ export class HomePage implements OnInit, OnDestroy, AfterViewChecked { }); } + /** + * ID references cannot cross Ionic's shadow boundary. Newer browsers can + * link the native tab directly to a light DOM panel through element references. + * Older browsers retain Ionic's tab semantics without an invalid shadow IDREF. + */ + private linkContentTabs(): void { + const host = this.activityCol?.el; + if (!host) { + return; + } + host.querySelectorAll('ion-segment-button').forEach(button => { + const linkPanel = () => { + const native = button.shadowRoot?.querySelector('button'); + const controls = button.getAttribute('aria-controls'); + const panel = controls ? host.querySelector(`#${controls}`) : null; + if (native && panel && 'ariaControlsElements' in native && native.ariaControlsElements?.[0] !== panel) { + native.ariaControlsElements = [panel]; + } + }; + if (button.shadowRoot?.querySelector('button')) { + linkPanel(); + } else if (button.componentOnReady && !this.pendingContentTabs.has(button)) { + // A newly rendered Ionic element may hydrate after Angular checks the view. + this.pendingContentTabs.add(button); + button.componentOnReady().then(() => { + this.pendingContentTabs.delete(button); + if (host.isConnected) { + linkPanel(); + } + }).catch(() => this.pendingContentTabs.delete(button)); + } + }); + } + ngOnInit() { this.updateUserRoleState(); this.pulseCheckIndicatorEnabled = this.storageService.getFeature('pulseCheckIndicator'); @@ -364,33 +400,13 @@ export class HomePage implements OnInit, OnDestroy, AfterViewChecked { this.isExpertWithoutTeam = this.isExpert && !teamId; } - switchContent(value: string) { + switchContent(event) { // update points upon switching to badges tab - if (value === 'badges') { + if (event.detail.value === "badges") { this.getIsPointsConfigured = this.achievementService.isPointsConfigured; this.getEarnedPoints = this.achievementService.earnedPoints; } - this.display = value; - } - - navigateContentTabs(event: KeyboardEvent): void { - const current = event.target as HTMLElement; - const tabs = Array.from(current.closest('[role="tablist"]')?.querySelectorAll('[role="tab"]') || []); - const index = tabs.indexOf(current as HTMLButtonElement); - if (index < 0) { - return; - } - let next: number; - switch (event.key) { - case 'ArrowRight': next = (index + 1) % tabs.length; break; - case 'ArrowLeft': next = (index + tabs.length - 1) % tabs.length; break; - case 'Home': next = 0; break; - case 'End': next = tabs.length - 1; break; - default: return; - } - event.preventDefault(); - tabs[next].click(); - tabs[next].focus(); + this.display = event.detail.value; } endingIcon(activity) { From c7dab580d171d7a72c75c6736e01c481acd0a24e Mon Sep 17 00:00:00 2001 From: chaw Date: Wed, 11 Nov 2026 14:27:20 +0800 Subject: [PATCH 4/4] fix: authenticate the selected experience timeline --- projects/v3/src/app/services/experience.service.spec.ts | 6 +++++- projects/v3/src/app/services/experience.service.ts | 1 + 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/projects/v3/src/app/services/experience.service.spec.ts b/projects/v3/src/app/services/experience.service.spec.ts index a4bea7cf31..1d7d23cd09 100644 --- a/projects/v3/src/app/services/experience.service.spec.ts +++ b/projects/v3/src/app/services/experience.service.spec.ts @@ -89,7 +89,7 @@ describe('ExperienceService', () => { expect(service).toBeTruthy(); }); - it('should initialise Pusher only after the selected experience is authenticated', async () => { + it('should authenticate the selected timeline before initialising Pusher', async () => { const callOrder: string[] = []; const sharedService = TestBed.inject(SharedService) as jasmine.SpyObj; const authService = TestBed.inject(AuthService) as jasmine.SpyObj; @@ -119,6 +119,10 @@ describe('ExperienceService', () => { await service.switchProgramAndNavigate(experience as any); + expect(authService.authenticate).toHaveBeenCalledWith({ + experienceUuid: 'experience-2', + timelineId: 222, + }); expect(callOrder).toEqual(['authenticate', 'pusher']); expect(storageService.setUser).toHaveBeenCalledWith({ apikey: 'new-api-key' }); expect(sharedService.initWebServices).toHaveBeenCalledTimes(1); diff --git a/projects/v3/src/app/services/experience.service.ts b/projects/v3/src/app/services/experience.service.ts index 7a1807c08d..72270e422d 100644 --- a/projects/v3/src/app/services/experience.service.ts +++ b/projects/v3/src/app/services/experience.service.ts @@ -355,6 +355,7 @@ export class ExperienceService { await this.switchProgram({ experience }); const authResponse = await firstValueFrom(this.authService.authenticate({ experienceUuid: experience.uuid, + timelineId: experience.timelineId, })); const apikey = authResponse?.data?.auth?.apikey;