Skip to content

Commit c08d638

Browse files
committed
MOBILE-4065 a11y: Hide pages under user tours
Following the same strategy as Ionic's built-in overlays https://github.com/ionic-team/ionic-framework/blob/1b30fc97d33e761866b4bcf7518efcdeb753032d/core/src/utils/overlays.ts#L388..L401
1 parent 77fb8f7 commit c08d638

File tree

4 files changed

+24
-3
lines changed

4 files changed

+24
-3
lines changed

src/core/features/block/components/side-blocks-tour/side-blocks-tour.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<h2>{{ 'core.block.tour_navigation_dashboard_title' | translate }}</h2>
1+
<h1>{{ 'core.block.tour_navigation_dashboard_title' | translate }}</h1>
22
<p>{{ 'core.block.tour_navigation_dashboard_content' | translate }}</p>
33
<ion-button (click)="dismiss()" expand="block">
44
{{ 'core.endonesteptour' | translate }}

src/core/features/course/components/course-index-tour/course-index-tour.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<h2>{{ 'core.course.tour_navigation_course_index_student_title' | translate }}</h2>
1+
<h1>{{ 'core.course.tour_navigation_course_index_student_title' | translate }}</h1>
22
<p>{{ 'core.course.tour_navigation_course_index_student_content' | translate }}</p>
33
<ion-button (click)="dismiss()" expand="block">
44
{{ 'core.endonesteptour' | translate }}

src/core/features/mainmenu/components/user-menu-tour/user-menu-tour.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<h2>{{ 'core.mainmenu.usermenutourtitle' | translate }}</h2>
1+
<h1>{{ 'core.mainmenu.usermenutourtitle' | translate }}</h1>
22
<p>{{ 'core.mainmenu.usermenutourdescription' | translate }}</p>
33
<ion-button (click)="dismiss()" expand="block">
44
{{ 'core.endonesteptour' | translate }}

src/core/features/usertours/services/user-tours.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,13 +115,16 @@ export class CoreUserToursService {
115115
await CoreUtils.wait(delay ?? 200);
116116

117117
const container = document.querySelector('ion-app') ?? document.body;
118+
const viewContainer = container.querySelector('ion-router-outlet, ion-nav, #ion-view-container-root');
118119
const element = await AngularFrameworkDelegate.attachViewToDom(
119120
container,
120121
CoreUserToursUserTourComponent,
121122
{ ...componentOptions, container },
122123
);
123124
const tour = CoreDirectivesRegistry.require(element, CoreUserToursUserTourComponent);
124125

126+
viewContainer?.setAttribute('aria-hidden', 'true');
127+
125128
return this.startTour(tour, options.watch ?? (options as CoreUserToursFocusedOptions).focus);
126129
}
127130

@@ -132,6 +135,15 @@ export class CoreUserToursService {
132135
*/
133136
async dismiss(acknowledge: boolean = true): Promise<void> {
134137
await this.getForegroundTour()?.dismiss(acknowledge);
138+
139+
if (this.hasVisibleTour()) {
140+
return;
141+
}
142+
143+
const container = document.querySelector('ion-app') ?? document.body;
144+
const viewContainer = container.querySelector('ion-router-outlet, ion-nav, #ion-view-container-root');
145+
146+
viewContainer?.removeAttribute('aria-hidden');
135147
}
136148

137149
/**
@@ -241,6 +253,15 @@ export class CoreUserToursService {
241253
return this.tours.find(({ visible }) => visible)?.component;
242254
}
243255

256+
/**
257+
* Check whether any tour is visible.
258+
*
259+
* @returns Whether any tour is visible.
260+
*/
261+
protected hasVisibleTour(): boolean {
262+
return this.tours.some(({ visible }) => visible);
263+
}
264+
244265
/**
245266
* Returns the tour index in the stack.
246267
*

0 commit comments

Comments
 (0)