@jskit-ai/shell-web 0.2.39 → 0.2.40
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +2 -0
- package/README.md +16 -0
- package/fixtures/adaptive-shell/src/NotesPage.vue +104 -0
- package/fixtures/adaptive-shell/src/main.js +2 -0
- package/package.json +1 -1
- package/src/client/components/ShellErrorHost.vue +2 -0
- package/src/client/components/ShellLayout.vue +11 -1
- package/src/client/composables/useShellInertBehindDialog.js +196 -0
- package/test/inertBehindDialog.browser.test.js +262 -0
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
## Unreleased
|
|
4
4
|
|
|
5
|
+
- The page behind an open modal dialog is inert, as the WAI-ARIA dialog pattern has it and as the dialog's scrim already had it for the pointer: while a `v-dialog` or a `v-bottom-sheet` is open, `ShellLayout`'s app bar, rail, drawer, main (with the page's FAB and its other actions), navigation bar and side sheet carry `inert`, so they take no focus, assistive technology skips them and axe judges only the dialog, its target-size rule included. Before, the page stayed live in the accessibility tree under the scrim: axe's target-size rule judged a note's Edit button and a card link behind the scrim as targets, and an app had to narrow its axe checks to the topmost dialog. Vuetify's overlay layer, where it teleports dialogs, menus, tooltips and snackbars, is never inert, so a select or menu opened in the dialog works and a snackbar shown over it is announced; of two dialogs open at once, the lower is inert under the upper until that closes. The shell sees every dialog, an app's and JSKIT's own (`ShellErrorHost`'s, auth-web's `SecondFactorDialog`), by watching the document for Vuetify's open modal overlays (`.v-overlay--active[aria-modal="true"]`), with no dialog component of its own. The page is live again the moment its dialog closes or unmounts, before the dialog gives focus back, and focus then returns to the element that opened the dialog when it has nowhere else to be: Vuetify's own return to an activator runs while the page is still inert, and a dialog opened from `v-model`, with no activator, never had one. A dialog that closes by leaving its page leaves focus to the next page, and the page there is live. A dialog attached or contained inside the page (`attach`, `contained`) stays local to that part and leaves the page as it is. The parts the shell makes inert carry `data-shell-page`. An app that drew its own layout around `v-main` (with `useShellAppBar()`) does not get this.
|
|
6
|
+
- `ShellErrorHost`'s dialog has an accessible name, its title ("Attention required"), as a dialog must (WCAG 4.1.2, axe `aria-dialog-name`): Vuetify names no dialog itself, so it was a dialog with no name.
|
|
5
7
|
- The drawer's and the rail's navigation lists hold only list items (WCAG 1.3.1, axe `aria-required-children`): in a Vuetify list, each `ShellNavigationItem` (a drawer or rail destination, and a `ShellMenuLinkItem` or `ShellSurfaceAwareMenuLinkItem` in an app's own `v-list`, such as a settings section's) is a `role="listitem"` element holding its link, and the drawer's divider between the primary and secondary destinations is `role="presentation"`. Vuetify makes a link item in a list the link itself and draws the divider as an `hr`, a separator, so these lists held links and a separator, which axe reported on every screen. The destinations stay where they were: the list item keeps the 4dp Vuetify sets between a nav list's items, and the rail still spaces its own. Outside a list, as in the navigation bar, an item is its link alone, as before, and attributes given to an item still land on its link.
|
|
6
8
|
- A command button keeps keyboard focus while its action runs. `ShellPageAction` and `ShellPrimaryAction` take `pending` (the action is running; give it a pending label, such as "Saving…"), and `loading` now means the same with Vuetify's progress indicator: the button stays enabled and focused, reads as unavailable (`aria-disabled="true"`) and ignores a click, Enter, Space or a form's implicit submission through it until the action settles, and it is never `disabled` meanwhile, even with `disabled` set too (as `addEdit.isSubmitDisabled` is while a save runs). Any other button, or a component that wraps one such as `v-fab`, takes the new `v-pending` directive (`@jskit-ai/shell-web/client/directives/vPending`, also `vPending` from `@jskit-ai/shell-web/client`). When the action settles with focus still on its button, focus moves to the first field its refusal marked (a Vuetify field in its error state, or one with `aria-invalid="true"`; within it, the first enabled control, so a radio group whose current choice is disabled gets its first enabled one) in the button's form, else its dialog, else the page; with none it stays on the button. Before, a running action's button was `disabled`, and Chromium moves the focus of a button that becomes disabled to the page body, so a keyboard user who pressed Save, Send or "Load more" landed back at the top of the page; a `loading` button kept focus but ran again on a second Enter. The app bar's overflow menu shows a pending action as unavailable, as it showed a loading one.
|
|
7
9
|
- **Breaking:** the shell's banner names the page's environment from the `jskit-app-environment` meta tag: "Development", "Test" or "Staging", and none in production. It replaces the "Test copy" banner; its id and test id are `jskit-app-environment-banner`, and the shell runtime's key is `appEnvironmentBanner`. It is still a note that never takes a click, with the environment's sentence as its description and no label.
|
package/README.md
CHANGED
|
@@ -24,3 +24,19 @@ elsewhere on the page stay. Medium and wider bars show them all.
|
|
|
24
24
|
`ShellErrorHost` centres its snackbar above the navigation bar on compact
|
|
25
25
|
windows and starts it at the content's start edge, at most half the content's
|
|
26
26
|
width, on wider ones, so it never covers the FAB or the actions it reports on.
|
|
27
|
+
|
|
28
|
+
## The page behind a dialog
|
|
29
|
+
|
|
30
|
+
While a `v-dialog` or `v-bottom-sheet` is open, `ShellLayout` makes its page
|
|
31
|
+
inert under it: the app bar, the rail, the drawer, main (with the page's FAB),
|
|
32
|
+
the navigation bar and the side sheet, each marked `data-shell-page`. A
|
|
33
|
+
keyboard, assistive technology and axe then skip the page, as the scrim already
|
|
34
|
+
makes the pointer skip it, so an app runs its axe checks on the whole document
|
|
35
|
+
with a dialog open instead of narrowing them to the dialog. Vuetify's overlay
|
|
36
|
+
layer stays live: a menu or select opened in the dialog, a second dialog over
|
|
37
|
+
it (the first is inert under it until it closes) and a snackbar, which is still
|
|
38
|
+
announced. When the dialog closes, or unmounts, the page is live again and
|
|
39
|
+
focus returns to the element that opened it unless focus already went
|
|
40
|
+
somewhere; a dialog that closes by leaving its page leaves focus to the next
|
|
41
|
+
page. A dialog attached or contained inside the page stays local and leaves the
|
|
42
|
+
page alone.
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
import { ref } from "vue";
|
|
3
|
+
import { RouterLink } from "vue-router";
|
|
4
|
+
import { useShellWebErrorRuntime } from "@jskit-ai/shell-web/client/error";
|
|
5
|
+
import ShellPrimaryAction from "../../../src/client/components/ShellPrimaryAction.vue";
|
|
6
|
+
|
|
7
|
+
// Dialogs over a page, for the page behind them: a note card with its Edit button and a link, and the FAB, whose
|
|
8
|
+
// "Invite" opens a dialog from v-model with no activator. The dialog is as tall as a form that fills most of a phone,
|
|
9
|
+
// so its "Send invitation" sits where the FAB is. In it: a select (a menu over the dialog), "Copy link" (a snackbar
|
|
10
|
+
// while the dialog is open), "Remove access" (a second dialog over the first) and "Open contacts" (a link that leaves
|
|
11
|
+
// the page with the dialog open). "Note details" opens a dialog from its activator; "Report a problem" opens the
|
|
12
|
+
// shell's own error dialog. Presses of the note's Edit and the dialogs' actions are counted.
|
|
13
|
+
const errorRuntime = useShellWebErrorRuntime();
|
|
14
|
+
const invite = ref(false);
|
|
15
|
+
const removeAccess = ref(false);
|
|
16
|
+
const role = ref("Viewer");
|
|
17
|
+
const presses = ref([]);
|
|
18
|
+
|
|
19
|
+
function press(name) {
|
|
20
|
+
presses.value.push(name);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function copyLink() {
|
|
24
|
+
press("copy");
|
|
25
|
+
errorRuntime.report({
|
|
26
|
+
source: "fixture.notes.copy",
|
|
27
|
+
message: "Invitation link copied.",
|
|
28
|
+
intent: "action-feedback",
|
|
29
|
+
severity: "success",
|
|
30
|
+
channel: "snackbar"
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function reportProblem() {
|
|
35
|
+
errorRuntime.report({
|
|
36
|
+
source: "fixture.notes.problem",
|
|
37
|
+
message: "The note could not be shared.",
|
|
38
|
+
severity: "error",
|
|
39
|
+
channel: "dialog"
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
</script>
|
|
43
|
+
|
|
44
|
+
<template>
|
|
45
|
+
<section class="d-flex flex-column ga-4 pa-4">
|
|
46
|
+
<v-card title="Kitchen note" data-testid="fixture-note">
|
|
47
|
+
<v-card-text>Order more flour before Friday.</v-card-text>
|
|
48
|
+
<v-card-actions>
|
|
49
|
+
<v-btn icon="$edit" variant="text" aria-label="Edit note" data-testid="fixture-note-edit" @click="press('edit')" />
|
|
50
|
+
<RouterLink to="/home/contacts" data-testid="fixture-note-link">Supplier contacts</RouterLink>
|
|
51
|
+
</v-card-actions>
|
|
52
|
+
</v-card>
|
|
53
|
+
|
|
54
|
+
<div class="d-flex flex-wrap ga-2">
|
|
55
|
+
<v-dialog max-width="400" aria-label="Note details">
|
|
56
|
+
<template #activator="{ props: activator }">
|
|
57
|
+
<v-btn variant="text" data-testid="fixture-note-details" v-bind="activator">Note details</v-btn>
|
|
58
|
+
</template>
|
|
59
|
+
<template #default="{ isActive }">
|
|
60
|
+
<v-card title="Note details" data-testid="fixture-details-dialog">
|
|
61
|
+
<v-card-text>Written on Monday.</v-card-text>
|
|
62
|
+
<v-card-actions>
|
|
63
|
+
<v-spacer />
|
|
64
|
+
<v-btn variant="text" data-testid="fixture-details-close" @click="isActive.value = false">Close</v-btn>
|
|
65
|
+
</v-card-actions>
|
|
66
|
+
</v-card>
|
|
67
|
+
</template>
|
|
68
|
+
</v-dialog>
|
|
69
|
+
<v-btn variant="text" data-testid="fixture-report-problem" @click="reportProblem">Report a problem</v-btn>
|
|
70
|
+
</div>
|
|
71
|
+
<p data-testid="fixture-notes-presses">{{ presses.join(",") }}</p>
|
|
72
|
+
|
|
73
|
+
<v-dialog v-model="invite" max-width="480" height="600" aria-label="Invite someone">
|
|
74
|
+
<v-card title="Invite someone" data-testid="fixture-invite-dialog">
|
|
75
|
+
<v-card-text class="d-flex flex-column ga-2">
|
|
76
|
+
<v-select v-model="role" label="Role" :items="['Viewer', 'Editor', 'Owner']" data-testid="fixture-invite-role" />
|
|
77
|
+
<div class="d-flex flex-wrap ga-2">
|
|
78
|
+
<v-btn variant="text" data-testid="fixture-invite-copy" @click="copyLink">Copy link</v-btn>
|
|
79
|
+
<v-btn variant="text" data-testid="fixture-invite-remove" @click="removeAccess = true">Remove access</v-btn>
|
|
80
|
+
<v-btn variant="text" to="/home/contacts" data-testid="fixture-invite-contacts">Open contacts</v-btn>
|
|
81
|
+
</div>
|
|
82
|
+
</v-card-text>
|
|
83
|
+
<v-card-actions>
|
|
84
|
+
<v-spacer />
|
|
85
|
+
<v-btn variant="text" data-testid="fixture-invite-cancel" @click="invite = false">Cancel</v-btn>
|
|
86
|
+
<v-btn variant="text" data-testid="fixture-invite-send" @click="press('send'); invite = false">Send invitation</v-btn>
|
|
87
|
+
</v-card-actions>
|
|
88
|
+
</v-card>
|
|
89
|
+
</v-dialog>
|
|
90
|
+
|
|
91
|
+
<v-dialog v-model="removeAccess" max-width="320" aria-label="Remove access?">
|
|
92
|
+
<v-card title="Remove access?" data-testid="fixture-remove-dialog">
|
|
93
|
+
<v-card-text>They can no longer open this note.</v-card-text>
|
|
94
|
+
<v-card-actions>
|
|
95
|
+
<v-spacer />
|
|
96
|
+
<v-btn variant="text" data-testid="fixture-remove-keep" @click="removeAccess = false">Keep</v-btn>
|
|
97
|
+
<v-btn variant="text" data-testid="fixture-remove-confirm" @click="press('remove'); removeAccess = false">Remove</v-btn>
|
|
98
|
+
</v-card-actions>
|
|
99
|
+
</v-card>
|
|
100
|
+
</v-dialog>
|
|
101
|
+
|
|
102
|
+
<ShellPrimaryAction label="Invite" icon="$add" data-testid="fixture-invite" @click="invite = true" />
|
|
103
|
+
</section>
|
|
104
|
+
</template>
|
|
@@ -18,6 +18,7 @@ import { adminTheme, theme } from "./theme/index.js";
|
|
|
18
18
|
import RecordListPage from "./RecordListPage.vue";
|
|
19
19
|
import RecordPage from "./RecordPage.vue";
|
|
20
20
|
import FeedbackPage from "./FeedbackPage.vue";
|
|
21
|
+
import NotesPage from "./NotesPage.vue";
|
|
21
22
|
import PendingActionsPage from "./PendingActionsPage.vue";
|
|
22
23
|
import DialogFeedbackPage from "./DialogFeedbackPage.vue";
|
|
23
24
|
import ReportsPage from "./ReportsPage.vue";
|
|
@@ -346,6 +347,7 @@ const routes = [
|
|
|
346
347
|
{ path: "/home/pending", component: PendingActionsPage, meta: { jskit: { title: "Pending actions" } } },
|
|
347
348
|
{ path: "/home/pending-dialog", component: () => import("./PendingDialogPage.vue"), meta: { jskit: { title: "Invites" } } },
|
|
348
349
|
// A layout that draws its own top app bar from the shell's pieces.
|
|
350
|
+
{ path: "/home/notes", component: NotesPage, meta: { jskit: { title: "Notes" } } },
|
|
349
351
|
{ path: "/home/studio", component: StudioPage, meta: { ownBar: true, jskit: { title: "Studio" } } },
|
|
350
352
|
{ path: "/home/studio/:id", component: StudioPage, meta: { ownBar: true, jskit: { parent: "/studio" } } },
|
|
351
353
|
{ path: "/home/:section?", component: ScreenPage, meta: { title: "Home surface" } },
|
package/package.json
CHANGED
|
@@ -116,8 +116,10 @@ const {
|
|
|
116
116
|
</template>
|
|
117
117
|
</v-snackbar>
|
|
118
118
|
|
|
119
|
+
<!-- Named by its title, as a dialog must be (WCAG 4.1.2, axe aria-dialog-name): Vuetify names no dialog itself. -->
|
|
119
120
|
<v-dialog
|
|
120
121
|
:model-value="Boolean(dialogEntry)"
|
|
122
|
+
:aria-label="t('jskit.shell.error.attentionRequired')"
|
|
121
123
|
max-width="560"
|
|
122
124
|
:persistent="Boolean(dialogEntry?.persist)"
|
|
123
125
|
@update:model-value="onDialogModelValue"
|
|
@@ -3,6 +3,7 @@ import { computed, inject, onBeforeUnmount, onMounted, ref, useSlots } from "vue
|
|
|
3
3
|
import { useDisplay } from "vuetify";
|
|
4
4
|
import { useShellAppBar } from "../composables/useShellAppBar.js";
|
|
5
5
|
import { useShellDrawer } from "../composables/useShellDrawer.js";
|
|
6
|
+
import { useShellInertBehindDialog } from "../composables/useShellInertBehindDialog.js";
|
|
6
7
|
import { useShellOutletPlacements } from "../composables/useShellOutletPlacements.js";
|
|
7
8
|
import { useShellLayoutState } from "../composables/useShellLayoutState.js";
|
|
8
9
|
import { useShellPullToRefresh } from "../composables/useShellPullToRefresh.js";
|
|
@@ -168,6 +169,10 @@ const { inMenu: topRightInMenu } = useShellTopRightOverflow({
|
|
|
168
169
|
menuId: TOP_RIGHT_MENU_ID
|
|
169
170
|
});
|
|
170
171
|
|
|
172
|
+
// While a dialog or a bottom sheet is open, each part of the page marked `data-shell-page` is inert under it: the app
|
|
173
|
+
// bar, the navigation, main with the page's FAB, and the side sheet.
|
|
174
|
+
useShellInertBehindDialog();
|
|
175
|
+
|
|
171
176
|
function updateScrolled() {
|
|
172
177
|
scrolled.value = window.scrollY > 0;
|
|
173
178
|
}
|
|
@@ -189,6 +194,7 @@ onBeforeUnmount(() => {
|
|
|
189
194
|
:height="64"
|
|
190
195
|
class="shell-layout__app-bar"
|
|
191
196
|
:class="`shell-layout--size-${sizeClass}`"
|
|
197
|
+
data-shell-page
|
|
192
198
|
data-testid="jskit-shell-app-bar"
|
|
193
199
|
:data-size-class="sizeClass"
|
|
194
200
|
>
|
|
@@ -266,6 +272,7 @@ onBeforeUnmount(() => {
|
|
|
266
272
|
<v-navigation-drawer
|
|
267
273
|
v-if="showsMediumRail"
|
|
268
274
|
class="shell-layout__rail"
|
|
275
|
+
data-shell-page
|
|
269
276
|
data-testid="jskit-shell-rail"
|
|
270
277
|
data-presentation="rail"
|
|
271
278
|
:style="navigationStyle"
|
|
@@ -301,6 +308,7 @@ onBeforeUnmount(() => {
|
|
|
301
308
|
id="jskit-shell-drawer"
|
|
302
309
|
:model-value="drawerPresentation.visible"
|
|
303
310
|
class="shell-layout__drawer"
|
|
311
|
+
data-shell-page
|
|
304
312
|
data-testid="jskit-shell-drawer"
|
|
305
313
|
:data-layout="layoutClass"
|
|
306
314
|
:data-presentation="drawerPresentation.kind"
|
|
@@ -359,7 +367,7 @@ onBeforeUnmount(() => {
|
|
|
359
367
|
</slot>
|
|
360
368
|
</v-navigation-drawer>
|
|
361
369
|
|
|
362
|
-
<v-main class="bg-background">
|
|
370
|
+
<v-main class="bg-background" data-shell-page>
|
|
363
371
|
<div class="shell-layout__content" :class="{ 'shell-layout__content--compact': isCompactLayout }">
|
|
364
372
|
<ShellRouteTransition>
|
|
365
373
|
<slot />
|
|
@@ -370,6 +378,7 @@ onBeforeUnmount(() => {
|
|
|
370
378
|
<v-bottom-navigation
|
|
371
379
|
v-if="showsBottomNavigation"
|
|
372
380
|
class="shell-layout__bottom-nav"
|
|
381
|
+
data-shell-page
|
|
373
382
|
data-testid="jskit-shell-bottom-nav"
|
|
374
383
|
bg-color="surface-container"
|
|
375
384
|
:elevation="0"
|
|
@@ -401,6 +410,7 @@ onBeforeUnmount(() => {
|
|
|
401
410
|
v-if="!isCompactLayout"
|
|
402
411
|
:model-value="supportingContentOpen"
|
|
403
412
|
class="shell-layout__supporting-side-sheet"
|
|
413
|
+
data-shell-page
|
|
404
414
|
color="surface-container-low"
|
|
405
415
|
temporary
|
|
406
416
|
location="right"
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
import { onBeforeUnmount, onMounted } from "vue";
|
|
2
|
+
import { useRoute } from "vue-router";
|
|
3
|
+
|
|
4
|
+
// An open modal dialog: a Vuetify overlay that declares itself modal, as every `v-dialog` and `v-bottom-sheet` does
|
|
5
|
+
// (a bottom sheet is a dialog), JSKIT's own and an app's, while it is active.
|
|
6
|
+
const OPEN_MODAL_DIALOG = ".v-overlay.v-overlay--active[aria-modal='true']";
|
|
7
|
+
// A part of the page, as `ShellLayout` marks each: the app bar, the rail, the drawer, main, the navigation bar and the
|
|
8
|
+
// side sheet.
|
|
9
|
+
const SHELL_PAGE = "[data-shell-page]";
|
|
10
|
+
// What can open, close or reorder a dialog, or add a part of the page: a Vuetify overlay and a page part.
|
|
11
|
+
const WATCHED = `.v-overlay, ${SHELL_PAGE}`;
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Vuetify stacks each overlay it opens 10 above the one opened before (its inline z-index); at one z-index the later
|
|
15
|
+
* in the document is on top.
|
|
16
|
+
* @param {HTMLElement} first
|
|
17
|
+
* @param {HTMLElement} second
|
|
18
|
+
*/
|
|
19
|
+
function stackOrder(first, second) {
|
|
20
|
+
const difference = (Number.parseInt(first.style.zIndex, 10) || 0) - (Number.parseInt(second.style.zIndex, 10) || 0);
|
|
21
|
+
if (difference !== 0) {
|
|
22
|
+
return difference;
|
|
23
|
+
}
|
|
24
|
+
return first.compareDocumentPosition(second) & Node.DOCUMENT_POSITION_FOLLOWING ? -1 : 1;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Whether a batch of mutations can have opened, closed or reordered a dialog, or replaced a part of the page: an
|
|
29
|
+
* overlay's class changed (Vuetify marks an open one `v-overlay--active`), or an overlay or a page part came or went.
|
|
30
|
+
* Every other change on the page, such as a ripple or a field's focus class, is left at that.
|
|
31
|
+
* @param {MutationRecord[]} records
|
|
32
|
+
*/
|
|
33
|
+
function concernsDialogs(records) {
|
|
34
|
+
for (const record of records) {
|
|
35
|
+
if (record.type === "attributes") {
|
|
36
|
+
if (/** @type {Element} */ (record.target).classList.contains("v-overlay")) {
|
|
37
|
+
return true;
|
|
38
|
+
}
|
|
39
|
+
continue;
|
|
40
|
+
}
|
|
41
|
+
for (const nodes of [record.addedNodes, record.removedNodes]) {
|
|
42
|
+
for (const node of nodes) {
|
|
43
|
+
if (node instanceof Element && (node.matches(WATCHED) || node.querySelector(WATCHED))) {
|
|
44
|
+
return true;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
return false;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Makes the page behind an open modal dialog inert, as the WAI-ARIA dialog pattern does and as the dialog's scrim
|
|
54
|
+
* already does for the pointer: while a `v-dialog` or `v-bottom-sheet` is open, every part of the page `ShellLayout`
|
|
55
|
+
* marks with `data-shell-page` (the app bar, the rail, the drawer, main with its FAB, the navigation bar and the side
|
|
56
|
+
* sheet) is `inert`, so a keyboard, assistive technology and accessibility checks such as axe skip it. Vuetify's
|
|
57
|
+
* overlay layer, where it teleports dialogs, menus, tooltips and snackbars, is never made inert, so a menu or select
|
|
58
|
+
* opened in the dialog works and a snackbar is announced; of two dialogs open at once, the lower is inert under the
|
|
59
|
+
* upper. A dialog attached inside a part of the page (`attach`, `contained`) stays local to it and leaves the page
|
|
60
|
+
* alone.
|
|
61
|
+
*
|
|
62
|
+
* It watches the document for Vuetify's overlays, so it sees every dialog, whoever renders it, without a dialog
|
|
63
|
+
* component of its own. The page is live again as soon as the render that closes or unmounts its dialog ends, before
|
|
64
|
+
* code that waits for it (`await nextTick()`) gives focus back. Focus then returns to the element that opened the
|
|
65
|
+
* dialog when it has nowhere else to be: Vuetify's overlay gives focus to its activator during that render, while the
|
|
66
|
+
* page is still inert, and a dialog opened from `v-model`, with no activator, gets none. It does not when the dialog
|
|
67
|
+
* closed by leaving its page, where the shell's navigation places focus.
|
|
68
|
+
*/
|
|
69
|
+
function useShellInertBehindDialog() {
|
|
70
|
+
const route = useRoute();
|
|
71
|
+
/** @type {Map<HTMLElement, { opener: HTMLElement | null, path: string }>} each open dialog, its opener and page */
|
|
72
|
+
const open = new Map();
|
|
73
|
+
/** @type {Set<HTMLElement>} the dialogs this made inert under the one on top */
|
|
74
|
+
const inertDialogs = new Set();
|
|
75
|
+
/** @type {EventTarget | null} */
|
|
76
|
+
let focused = null;
|
|
77
|
+
/** @type {EventTarget | null} */
|
|
78
|
+
let focusedBefore = null;
|
|
79
|
+
/** @type {MutationObserver | null} */
|
|
80
|
+
let observer = null;
|
|
81
|
+
|
|
82
|
+
/** @param {FocusEvent} event */
|
|
83
|
+
function trackFocus(event) {
|
|
84
|
+
if (event.target !== focused) {
|
|
85
|
+
focusedBefore = focused;
|
|
86
|
+
focused = event.target;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* The element that opened `dialog`: the one with focus as it opens, or the one before when the dialog has already
|
|
92
|
+
* taken focus (a field that focuses itself as it mounts). None when focus was nowhere.
|
|
93
|
+
* @param {HTMLElement} dialog
|
|
94
|
+
*/
|
|
95
|
+
function openerOf(dialog) {
|
|
96
|
+
const active = document.activeElement;
|
|
97
|
+
const element = active && dialog.contains(active) ? focusedBefore : active;
|
|
98
|
+
if (!(element instanceof HTMLElement) || element === document.body || !element.isConnected || dialog.contains(element)) {
|
|
99
|
+
return null;
|
|
100
|
+
}
|
|
101
|
+
return element;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/** @param {boolean} inert */
|
|
105
|
+
function setPageInert(inert) {
|
|
106
|
+
for (const part of document.querySelectorAll(SHELL_PAGE)) {
|
|
107
|
+
if (part instanceof HTMLElement && part.inert !== inert) {
|
|
108
|
+
part.inert = inert;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* After dialogs close, focus their opener (the top dialog's first) when focus is lost: on the page body, in a closed
|
|
115
|
+
* dialog or in an inert part. An opener that is gone, inert, or on a page the dialogs left is passed over.
|
|
116
|
+
* @param {HTMLElement[]} closed The dialogs that closed, the top one first.
|
|
117
|
+
*/
|
|
118
|
+
function returnFocus(closed) {
|
|
119
|
+
const active = document.activeElement;
|
|
120
|
+
const lost = !active ||
|
|
121
|
+
active === document.body ||
|
|
122
|
+
Boolean(active.closest("[inert]")) ||
|
|
123
|
+
closed.some((dialog) => dialog.contains(active));
|
|
124
|
+
if (!lost) {
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
for (const { opener, path } of closed.map((dialog) => open.get(dialog))) {
|
|
128
|
+
if (path !== route.path || !opener?.isConnected || opener.closest("[inert]")) {
|
|
129
|
+
continue;
|
|
130
|
+
}
|
|
131
|
+
opener.focus({ preventScroll: true });
|
|
132
|
+
if (document.activeElement === opener) {
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
function update() {
|
|
139
|
+
const dialogs = [...document.querySelectorAll(OPEN_MODAL_DIALOG)]
|
|
140
|
+
.filter((dialog) => dialog instanceof HTMLElement && !dialog.closest(SHELL_PAGE))
|
|
141
|
+
.sort(stackOrder);
|
|
142
|
+
// A dialog's opener is read before anything turns inert, which takes focus from it.
|
|
143
|
+
for (const dialog of dialogs) {
|
|
144
|
+
if (!open.has(dialog)) {
|
|
145
|
+
open.set(dialog, { opener: openerOf(dialog), path: route.path });
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
const top = dialogs.at(-1);
|
|
149
|
+
const lower = new Set(dialogs.filter((dialog) => dialog !== top && !dialog.contains(top)));
|
|
150
|
+
for (const dialog of inertDialogs) {
|
|
151
|
+
if (!lower.has(dialog)) {
|
|
152
|
+
dialog.inert = false;
|
|
153
|
+
inertDialogs.delete(dialog);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
for (const dialog of lower) {
|
|
157
|
+
if (!dialog.inert) {
|
|
158
|
+
dialog.inert = true;
|
|
159
|
+
inertDialogs.add(dialog);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
const closed = [...open.keys()].filter((dialog) => !dialogs.includes(dialog)).sort(stackOrder).reverse();
|
|
163
|
+
setPageInert(dialogs.length > 0);
|
|
164
|
+
if (closed.length > 0) {
|
|
165
|
+
returnFocus(closed);
|
|
166
|
+
for (const dialog of closed) {
|
|
167
|
+
open.delete(dialog);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
onMounted(() => {
|
|
173
|
+
document.addEventListener("focusin", trackFocus, true);
|
|
174
|
+
observer = new MutationObserver((records) => {
|
|
175
|
+
if (concernsDialogs(records)) {
|
|
176
|
+
update();
|
|
177
|
+
}
|
|
178
|
+
});
|
|
179
|
+
observer.observe(document.body, { subtree: true, childList: true, attributes: true, attributeFilter: ["class"] });
|
|
180
|
+
update();
|
|
181
|
+
});
|
|
182
|
+
|
|
183
|
+
onBeforeUnmount(() => {
|
|
184
|
+
document.removeEventListener("focusin", trackFocus, true);
|
|
185
|
+
observer?.disconnect();
|
|
186
|
+
observer = null;
|
|
187
|
+
for (const dialog of inertDialogs) {
|
|
188
|
+
dialog.inert = false;
|
|
189
|
+
}
|
|
190
|
+
inertDialogs.clear();
|
|
191
|
+
open.clear();
|
|
192
|
+
setPageInert(false);
|
|
193
|
+
});
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
export { useShellInertBehindDialog };
|
|
@@ -0,0 +1,262 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import { createRequire } from "node:module";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import process from "node:process";
|
|
5
|
+
import test from "node:test";
|
|
6
|
+
import { fileURLToPath } from "node:url";
|
|
7
|
+
import { expect } from "@playwright/test";
|
|
8
|
+
import { sharedBrowserFixture } from "../../../tooling/testUtils/browserFixture.mjs";
|
|
9
|
+
|
|
10
|
+
// The page behind an open modal dialog is inert, as the WAI-ARIA dialog pattern has it and as the scrim already has it
|
|
11
|
+
// for the pointer: ShellLayout's app bar, navigation, main and FAB take no focus and are left out of the accessibility
|
|
12
|
+
// tree and of axe's checks, while Vuetify's overlay layer (the dialog, a menu opened in it, a second dialog, a
|
|
13
|
+
// snackbar) stays live. When the dialog closes the page is live again and focus is back on the element that opened it.
|
|
14
|
+
const SKIP = process.env.JSKIT_SHELL_WEB_BROWSER_INTEGRATION === "1"
|
|
15
|
+
? false
|
|
16
|
+
: "set JSKIT_SHELL_WEB_BROWSER_INTEGRATION=1 to check the page behind a dialog is inert";
|
|
17
|
+
const FIXTURE_ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "../fixtures/adaptive-shell");
|
|
18
|
+
// axe-core as the page runs it, with every WCAG 2.2 A and AA rule, target-size included, and the best practices.
|
|
19
|
+
const AXE_PATH = createRequire(import.meta.url).resolve("axe-core/axe.min.js");
|
|
20
|
+
const STRICT_AXE_TAGS = Object.freeze(["wcag2a", "wcag2aa", "wcag21a", "wcag21aa", "wcag22aa", "best-practice"]);
|
|
21
|
+
const open = sharedBrowserFixture({ fixtureRoot: FIXTURE_ROOT, configFile: "vite.config.mjs" });
|
|
22
|
+
const COMPACT = Object.freeze({ width: 390, height: 844 });
|
|
23
|
+
const EXPANDED = Object.freeze({ width: 1280, height: 900 });
|
|
24
|
+
|
|
25
|
+
async function openNotes(t, viewport) {
|
|
26
|
+
const { vite, browser } = await open(t);
|
|
27
|
+
const page = await browser.newPage({ baseURL: vite.baseURL, viewport, reducedMotion: "reduce" });
|
|
28
|
+
await page.goto("/home/notes");
|
|
29
|
+
await expect(page.getByTestId("fixture-note-edit")).toBeVisible();
|
|
30
|
+
return page;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// The button inside `locator` when it wraps one (a FAB), else the element itself.
|
|
34
|
+
function buttonOf(locator) {
|
|
35
|
+
return locator.locator("xpath=self::button | self::a | .//button | .//a").first();
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// Focuses an element and presses Enter on it, as a keyboard user activates it.
|
|
39
|
+
async function activate(locator) {
|
|
40
|
+
await locator.focus();
|
|
41
|
+
await expect(locator).toBeFocused();
|
|
42
|
+
await locator.press("Enter");
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// The parts of the page ShellLayout makes inert, and whether each is.
|
|
46
|
+
function readPageParts(page) {
|
|
47
|
+
return page.evaluate(() => [...document.querySelectorAll("[data-shell-page]")].map((part) => part.inert));
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// Every part of the page, the app bar, the navigation and main at least, inert or else live.
|
|
51
|
+
async function expectPageInert(page, inert, message) {
|
|
52
|
+
await expect.poll(async () => {
|
|
53
|
+
const parts = await readPageParts(page);
|
|
54
|
+
return parts.length >= 3 && parts.every((part) => part === inert);
|
|
55
|
+
}, { message: `${message}: every part of the page ${inert ? "inert" : "live"}` }).toBe(true);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// Whether `locator`'s element takes focus when asked, as a keyboard and assistive technology ask.
|
|
59
|
+
function takesFocus(locator) {
|
|
60
|
+
return locator.evaluate((element) => {
|
|
61
|
+
element.focus();
|
|
62
|
+
return document.activeElement === element;
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// The accessible names of the nodes assistive technology reaches, from Chromium's accessibility tree.
|
|
67
|
+
async function readAccessibleNames(page) {
|
|
68
|
+
const session = await page.context().newCDPSession(page);
|
|
69
|
+
try {
|
|
70
|
+
const { nodes } = await session.send("Accessibility.getFullAXTree");
|
|
71
|
+
return new Set(nodes.filter((node) => !node.ignored && node.name?.value).map((node) => node.name.value));
|
|
72
|
+
} finally {
|
|
73
|
+
await session.detach();
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// axe over the whole document, strict: each result's node, and whether it lies behind the dialogs (anywhere but
|
|
78
|
+
// Vuetify's overlay layer, the document itself aside). `targets` are the nodes target-size judged as targets.
|
|
79
|
+
async function runStrictAxe(page) {
|
|
80
|
+
if (!(await page.evaluate(() => Boolean(globalThis.axe)))) {
|
|
81
|
+
await page.addScriptTag({ path: AXE_PATH });
|
|
82
|
+
}
|
|
83
|
+
return page.evaluate(async (tags) => {
|
|
84
|
+
const results = await globalThis.axe.run(document, { runOnly: { type: "tag", values: tags } });
|
|
85
|
+
const behind = (selector) => {
|
|
86
|
+
const element = document.querySelector(selector);
|
|
87
|
+
return Boolean(element) && element !== document.documentElement && element !== document.body &&
|
|
88
|
+
!element.closest(".v-overlay-container");
|
|
89
|
+
};
|
|
90
|
+
const nodesOf = (rules) => rules.flatMap((rule) => rule.nodes.map((node) => ({
|
|
91
|
+
rule: rule.id,
|
|
92
|
+
target: node.target.join(" "),
|
|
93
|
+
behind: behind(String(node.target[0]))
|
|
94
|
+
})));
|
|
95
|
+
return {
|
|
96
|
+
violations: nodesOf(results.violations),
|
|
97
|
+
incompleteBehind: nodesOf(results.incomplete).filter((node) => node.behind),
|
|
98
|
+
targets: nodesOf([...results.passes, ...results.violations, ...results.incomplete].filter((rule) => rule.id === "target-size"))
|
|
99
|
+
};
|
|
100
|
+
}, STRICT_AXE_TAGS);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
// Waits for a dialog to finish opening: shown, with focus moved into it.
|
|
104
|
+
async function expectDialogOpen(page, dialog) {
|
|
105
|
+
await expect(dialog).toBeVisible();
|
|
106
|
+
await expect.poll(() => dialog.evaluate((element) => element.closest(".v-overlay")?.contains(document.activeElement)))
|
|
107
|
+
.toBe(true);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
test("the page behind a dialog takes no focus and is skipped by assistive technology and strict axe, target-size included; closing it gives focus back to the FAB", {
|
|
111
|
+
skip: SKIP,
|
|
112
|
+
timeout: 120_000
|
|
113
|
+
}, async (t) => {
|
|
114
|
+
const page = await openNotes(t, COMPACT);
|
|
115
|
+
const fab = buttonOf(page.getByTestId("fixture-invite"));
|
|
116
|
+
const noteEdit = page.getByTestId("fixture-note-edit");
|
|
117
|
+
const behind = [
|
|
118
|
+
["the note's Edit", noteEdit],
|
|
119
|
+
["the note's link", page.getByTestId("fixture-note-link")],
|
|
120
|
+
["the FAB", fab],
|
|
121
|
+
["a navigation bar destination", page.getByTestId("jskit-shell-bottom-nav").getByRole("link").first()]
|
|
122
|
+
];
|
|
123
|
+
|
|
124
|
+
// The FAB opens the dialog from v-model, so it has no activator for Vuetify to give focus back to.
|
|
125
|
+
await activate(fab);
|
|
126
|
+
const dialog = page.getByTestId("fixture-invite-dialog");
|
|
127
|
+
await expectDialogOpen(page, dialog);
|
|
128
|
+
for (const [name, element] of behind) {
|
|
129
|
+
assert.equal(await takesFocus(element), false, `${name} takes no focus behind the dialog`);
|
|
130
|
+
}
|
|
131
|
+
await expectDialogOpen(page, dialog);
|
|
132
|
+
|
|
133
|
+
const names = await readAccessibleNames(page);
|
|
134
|
+
for (const name of ["Edit note", "Supplier contacts", "Invite"]) {
|
|
135
|
+
assert.equal(names.has(name), false, `assistive technology reaches no "${name}" behind the dialog`);
|
|
136
|
+
}
|
|
137
|
+
assert.ok(names.has("Send invitation"), "assistive technology reaches the dialog's actions");
|
|
138
|
+
|
|
139
|
+
// The dialog's "Send invitation" sits where the FAB is: it is on top, and axe judges only the dialog's targets.
|
|
140
|
+
const send = page.getByTestId("fixture-invite-send");
|
|
141
|
+
assert.equal(
|
|
142
|
+
await send.evaluate((element) => {
|
|
143
|
+
const box = element.getBoundingClientRect();
|
|
144
|
+
return element.contains(document.elementFromPoint(box.right - 4, box.bottom - 4));
|
|
145
|
+
}),
|
|
146
|
+
true,
|
|
147
|
+
"the dialog's button is on top of the FAB"
|
|
148
|
+
);
|
|
149
|
+
const axe = await runStrictAxe(page);
|
|
150
|
+
assert.deepEqual(axe.violations, [], "strict axe finds no violation");
|
|
151
|
+
assert.deepEqual(axe.incompleteBehind, [], "strict axe has nothing to review behind the dialog");
|
|
152
|
+
assert.deepEqual(axe.targets.filter((node) => node.behind), [], "target-size judges no target behind the dialog");
|
|
153
|
+
assert.ok(axe.targets.some((node) => node.target.includes("fixture-invite-send")), "target-size judges the dialog's buttons");
|
|
154
|
+
await expectPageInert(page, true, "with the dialog open");
|
|
155
|
+
assert.deepEqual(
|
|
156
|
+
await page.evaluate(() => [...document.querySelectorAll(".v-overlay-container, .v-overlay--active")].map((element) => element.inert)),
|
|
157
|
+
[false, false],
|
|
158
|
+
"the overlay layer and the dialog stay live"
|
|
159
|
+
);
|
|
160
|
+
|
|
161
|
+
await activate(page.getByTestId("fixture-invite-cancel"));
|
|
162
|
+
await expect(dialog).toBeHidden();
|
|
163
|
+
await expectPageInert(page, false, "after the dialog closes");
|
|
164
|
+
await expect(fab).toBeFocused();
|
|
165
|
+
assert.equal(await takesFocus(noteEdit), true, "the note's Edit takes focus again");
|
|
166
|
+
await noteEdit.press("Enter");
|
|
167
|
+
await expect(page.getByTestId("fixture-notes-presses")).toHaveText("edit");
|
|
168
|
+
await page.close();
|
|
169
|
+
});
|
|
170
|
+
|
|
171
|
+
test("in a dialog, a select's menu works, a snackbar is announced and a second dialog leaves the first inert until it closes, focus going back to each opener", {
|
|
172
|
+
skip: SKIP,
|
|
173
|
+
timeout: 120_000
|
|
174
|
+
}, async (t) => {
|
|
175
|
+
const page = await openNotes(t, EXPANDED);
|
|
176
|
+
// On an expanded window the screen's primary action is the app bar's button.
|
|
177
|
+
const invite = page.getByTestId("fixture-invite");
|
|
178
|
+
await activate(invite);
|
|
179
|
+
const inviteDialog = page.getByTestId("fixture-invite-dialog");
|
|
180
|
+
await expectDialogOpen(page, inviteDialog);
|
|
181
|
+
await expectPageInert(page, true, "with the dialog open");
|
|
182
|
+
|
|
183
|
+
await page.getByTestId("fixture-invite-role").click();
|
|
184
|
+
const options = page.getByRole("listbox");
|
|
185
|
+
await expect(options).toBeVisible();
|
|
186
|
+
await options.getByRole("option", { name: "Editor" }).click();
|
|
187
|
+
await expect(options).toBeHidden();
|
|
188
|
+
await expect(page.getByTestId("fixture-invite-role")).toContainText("Editor");
|
|
189
|
+
|
|
190
|
+
await activate(page.getByTestId("fixture-invite-copy"));
|
|
191
|
+
const message = page.getByRole("status").filter({ hasText: "Invitation link copied." });
|
|
192
|
+
await expect(message).toBeVisible();
|
|
193
|
+
assert.equal(await message.evaluate((element) => Boolean(element.closest("[inert]"))), false, "the snackbar is live");
|
|
194
|
+
assert.ok((await readAccessibleNames(page)).has("Invitation link copied."), "assistive technology reaches the message");
|
|
195
|
+
await expectPageInert(page, true, "with a message over the dialog");
|
|
196
|
+
|
|
197
|
+
const remove = page.getByTestId("fixture-invite-remove");
|
|
198
|
+
await activate(remove);
|
|
199
|
+
const removeDialog = page.getByTestId("fixture-remove-dialog");
|
|
200
|
+
await expectDialogOpen(page, removeDialog);
|
|
201
|
+
const inertOf = (locator) => locator.evaluate((element) => element.closest(".v-overlay").inert);
|
|
202
|
+
assert.equal(await inertOf(inviteDialog), true, "the first dialog is inert under the second");
|
|
203
|
+
assert.equal(await inertOf(removeDialog), false, "the second dialog is live");
|
|
204
|
+
assert.equal(await takesFocus(page.getByTestId("fixture-invite-copy")), false, "the first dialog takes no focus");
|
|
205
|
+
const names = await readAccessibleNames(page);
|
|
206
|
+
assert.equal(names.has("Copy link"), false, "assistive technology skips the first dialog");
|
|
207
|
+
assert.ok(names.has("Keep"), "assistive technology reaches the second dialog");
|
|
208
|
+
await expectPageInert(page, true, "with two dialogs open");
|
|
209
|
+
|
|
210
|
+
await activate(page.getByTestId("fixture-remove-keep"));
|
|
211
|
+
await expect(removeDialog).toBeHidden();
|
|
212
|
+
assert.equal(await inertOf(inviteDialog), false, "the first dialog is live again");
|
|
213
|
+
await expect(remove).toBeFocused();
|
|
214
|
+
await expectPageInert(page, true, "with the first dialog still open");
|
|
215
|
+
|
|
216
|
+
await page.keyboard.press("Escape");
|
|
217
|
+
await expect(inviteDialog).toBeHidden();
|
|
218
|
+
await expectPageInert(page, false, "after both dialogs close");
|
|
219
|
+
await expect(invite).toBeFocused();
|
|
220
|
+
await page.close();
|
|
221
|
+
});
|
|
222
|
+
|
|
223
|
+
test("Vuetify's activator gets focus back, the shell's own error dialog makes the page inert too, and leaving the page with a dialog open leaves the next page live", {
|
|
224
|
+
skip: SKIP,
|
|
225
|
+
timeout: 120_000
|
|
226
|
+
}, async (t) => {
|
|
227
|
+
const page = await openNotes(t, COMPACT);
|
|
228
|
+
|
|
229
|
+
const details = page.getByTestId("fixture-note-details");
|
|
230
|
+
await activate(details);
|
|
231
|
+
const detailsDialog = page.getByTestId("fixture-details-dialog");
|
|
232
|
+
await expectDialogOpen(page, detailsDialog);
|
|
233
|
+
await expectPageInert(page, true, "with a dialog opened from its activator");
|
|
234
|
+
await page.keyboard.press("Escape");
|
|
235
|
+
await expect(detailsDialog).toBeHidden();
|
|
236
|
+
await expectPageInert(page, false, "after Escape");
|
|
237
|
+
await expect(details).toBeFocused();
|
|
238
|
+
|
|
239
|
+
// ShellErrorHost's dialog: one of JSKIT's own, rendered beside the layout rather than in the page.
|
|
240
|
+
const report = page.getByTestId("fixture-report-problem");
|
|
241
|
+
await activate(report);
|
|
242
|
+
const errorDialog = page.getByRole("dialog", { name: "Attention required" });
|
|
243
|
+
await expectDialogOpen(page, errorDialog);
|
|
244
|
+
await expectPageInert(page, true, "with the shell's error dialog open");
|
|
245
|
+
assert.equal(await takesFocus(page.getByTestId("fixture-note-edit")), false, "the note's Edit takes no focus");
|
|
246
|
+
assert.deepEqual((await runStrictAxe(page)).violations, [], "strict axe finds no violation");
|
|
247
|
+
await activate(errorDialog.getByRole("button", { name: "Close" }));
|
|
248
|
+
await expect(errorDialog).toBeHidden();
|
|
249
|
+
await expectPageInert(page, false, "after the error dialog closes");
|
|
250
|
+
await expect(report).toBeFocused();
|
|
251
|
+
|
|
252
|
+
await activate(buttonOf(page.getByTestId("fixture-invite")));
|
|
253
|
+
await expectDialogOpen(page, page.getByTestId("fixture-invite-dialog"));
|
|
254
|
+
await expectPageInert(page, true, "with the dialog open");
|
|
255
|
+
await activate(page.getByTestId("fixture-invite-contacts"));
|
|
256
|
+
await expect(page).toHaveURL(/\/home\/contacts$/u);
|
|
257
|
+
await expect(page.getByTestId("fixture-invite-dialog")).toHaveCount(0);
|
|
258
|
+
await expectPageInert(page, false, "on the page the dialog's link opened");
|
|
259
|
+
assert.equal(await page.locator(".v-overlay[inert]").count(), 0, "no dialog is left inert");
|
|
260
|
+
assert.equal(await takesFocus(page.locator("main a[href]").first()), true, "the next page takes focus");
|
|
261
|
+
await page.close();
|
|
262
|
+
});
|