@jskit-ai/shell-web 0.2.40 → 0.2.42
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 +8 -0
- package/fixtures/adaptive-shell/src/NotesPage.vue +21 -2
- package/package.json +1 -1
- package/src/client/components/ShellNavigationItem.vue +7 -3
- package/src/client/composables/useShellInertBehindDialog.js +85 -5
- package/test/adaptiveShell.browser.test.js +63 -0
- package/test/inertBehindDialog.browser.test.js +129 -5
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
## Unreleased
|
|
4
4
|
|
|
5
|
+
- A navigation rail label never breaks inside a word. A label wider than the rail wraps between its words to a second line, as Material 3's rail labels do, and only a label that needs a third line ends its second in an ellipsis, as before; a single word wider than the rail now ends in an ellipsis too, where it was split across two lines ("Administrati" over "on").
|
|
6
|
+
- Closing a dialog no longer makes a closed modal navigation drawer or side sheet reachable. The page behind a dialog made every part `ShellLayout` marks `data-shell-page` live when the dialog closed, and when the layout mounted, the closed drawer and side sheet included, which Vuetify keeps `inert` while they are closed, so their off-screen destinations and content took keyboard focus and assistive technology read them. Now only the parts the dialog made inert are made live again; a part already inert stays so, and a drawer that closes behind the dialog (a window that narrows, a link in the dialog) is inert once the dialog closes.
|
|
5
7
|
- 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
8
|
- `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.
|
|
7
9
|
- 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.
|
package/README.md
CHANGED
|
@@ -40,3 +40,11 @@ focus returns to the element that opened it unless focus already went
|
|
|
40
40
|
somewhere; a dialog that closes by leaving its page leaves focus to the next
|
|
41
41
|
page. A dialog attached or contained inside the page stays local and leaves the
|
|
42
42
|
page alone.
|
|
43
|
+
|
|
44
|
+
Only the parts the dialog made inert are made live again. A part already inert
|
|
45
|
+
of its own, as Vuetify keeps a closed modal drawer or side sheet, stays inert
|
|
46
|
+
after the dialog, and a drawer that closes behind the dialog (the window
|
|
47
|
+
narrows, or a link in the dialog leaves the page) is inert once the dialog
|
|
48
|
+
closes; one that opens behind it is inert until the dialog closes and live
|
|
49
|
+
after. A layout of an app's own that binds `inert` on a part it marks
|
|
50
|
+
`data-shell-page` keeps the value it binds in the same way.
|
|
@@ -9,10 +9,12 @@ import ShellPrimaryAction from "../../../src/client/components/ShellPrimaryActio
|
|
|
9
9
|
// so its "Send invitation" sits where the FAB is. In it: a select (a menu over the dialog), "Copy link" (a snackbar
|
|
10
10
|
// while the dialog is open), "Remove access" (a second dialog over the first) and "Open contacts" (a link that leaves
|
|
11
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.
|
|
12
|
+
// shell's own error dialog. The note's "Archive note" and the dialog's "Remove access" each have a tooltip and open a
|
|
13
|
+
// dialog. Presses of the note's Edit and the dialogs' actions are counted.
|
|
13
14
|
const errorRuntime = useShellWebErrorRuntime();
|
|
14
15
|
const invite = ref(false);
|
|
15
16
|
const removeAccess = ref(false);
|
|
17
|
+
const archive = ref(false);
|
|
16
18
|
const role = ref("Viewer");
|
|
17
19
|
const presses = ref([]);
|
|
18
20
|
|
|
@@ -48,6 +50,10 @@ function reportProblem() {
|
|
|
48
50
|
<v-card-actions>
|
|
49
51
|
<v-btn icon="$edit" variant="text" aria-label="Edit note" data-testid="fixture-note-edit" @click="press('edit')" />
|
|
50
52
|
<RouterLink to="/home/contacts" data-testid="fixture-note-link">Supplier contacts</RouterLink>
|
|
53
|
+
<v-btn icon variant="text" aria-label="Archive note" data-testid="fixture-note-archive" @click="archive = true">
|
|
54
|
+
<v-icon icon="$delete" />
|
|
55
|
+
<v-tooltip activator="parent" location="top" text="Archive note" />
|
|
56
|
+
</v-btn>
|
|
51
57
|
</v-card-actions>
|
|
52
58
|
</v-card>
|
|
53
59
|
|
|
@@ -76,7 +82,10 @@ function reportProblem() {
|
|
|
76
82
|
<v-select v-model="role" label="Role" :items="['Viewer', 'Editor', 'Owner']" data-testid="fixture-invite-role" />
|
|
77
83
|
<div class="d-flex flex-wrap ga-2">
|
|
78
84
|
<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">
|
|
85
|
+
<v-btn variant="text" data-testid="fixture-invite-remove" @click="removeAccess = true">
|
|
86
|
+
Remove access
|
|
87
|
+
<v-tooltip activator="parent" location="top" text="Asks before removing" />
|
|
88
|
+
</v-btn>
|
|
80
89
|
<v-btn variant="text" to="/home/contacts" data-testid="fixture-invite-contacts">Open contacts</v-btn>
|
|
81
90
|
</div>
|
|
82
91
|
</v-card-text>
|
|
@@ -99,6 +108,16 @@ function reportProblem() {
|
|
|
99
108
|
</v-card>
|
|
100
109
|
</v-dialog>
|
|
101
110
|
|
|
111
|
+
<v-dialog v-model="archive" max-width="320" aria-label="Archive this note?">
|
|
112
|
+
<v-card title="Archive this note?" data-testid="fixture-archive-dialog">
|
|
113
|
+
<v-card-text>It leaves the list of notes.</v-card-text>
|
|
114
|
+
<v-card-actions>
|
|
115
|
+
<v-spacer />
|
|
116
|
+
<v-btn variant="text" data-testid="fixture-archive-cancel" @click="archive = false">Cancel</v-btn>
|
|
117
|
+
</v-card-actions>
|
|
118
|
+
</v-card>
|
|
119
|
+
</v-dialog>
|
|
120
|
+
|
|
102
121
|
<ShellPrimaryAction label="Invite" icon="$add" data-testid="fixture-invite" @click="invite = true" />
|
|
103
122
|
</section>
|
|
104
123
|
</template>
|
package/package.json
CHANGED
|
@@ -186,21 +186,25 @@ Unwrapped.inheritAttrs = false;
|
|
|
186
186
|
color: rgb(var(--v-theme-on-secondary-container));
|
|
187
187
|
}
|
|
188
188
|
|
|
189
|
-
/* A rail label is shown in full: one wider than the rail wraps to a second line, as Material 3's rail
|
|
190
|
-
and only a label that needs a third line ends the second in an ellipsis.
|
|
189
|
+
/* A rail label is shown in full: one wider than the rail wraps to a second line between its words, as Material 3's rail
|
|
190
|
+
labels do, and only a label that needs a third line ends the second in an ellipsis. A word is never broken: one
|
|
191
|
+
wider than the rail ends in an ellipsis. */
|
|
191
192
|
.shell-menu-link-item__rail-label {
|
|
192
193
|
-webkit-box-orient: vertical;
|
|
193
194
|
-webkit-line-clamp: 2;
|
|
194
195
|
display: -webkit-box;
|
|
195
196
|
font-size: 0.75rem;
|
|
196
197
|
font-weight: 500;
|
|
198
|
+
hyphens: manual;
|
|
197
199
|
letter-spacing: 0.03125rem;
|
|
198
200
|
line-height: 1rem;
|
|
199
201
|
max-width: calc(var(--shell-navigation-rail-width, 80px) - 8px);
|
|
200
202
|
overflow: hidden;
|
|
201
|
-
overflow-wrap:
|
|
203
|
+
overflow-wrap: normal;
|
|
202
204
|
text-align: center;
|
|
205
|
+
text-overflow: ellipsis;
|
|
203
206
|
white-space: normal;
|
|
207
|
+
word-break: normal;
|
|
204
208
|
}
|
|
205
209
|
|
|
206
210
|
.shell-menu-link-item--rail.v-list-item--active .shell-menu-link-item__rail-label {
|
|
@@ -57,7 +57,13 @@ function concernsDialogs(records) {
|
|
|
57
57
|
* overlay layer, where it teleports dialogs, menus, tooltips and snackbars, is never made inert, so a menu or select
|
|
58
58
|
* opened in the dialog works and a snackbar is announced; of two dialogs open at once, the lower is inert under the
|
|
59
59
|
* upper. A dialog attached inside a part of the page (`attach`, `contained`) stays local to it and leaves the page
|
|
60
|
-
* alone.
|
|
60
|
+
* alone. What turns inert lets go first: focus in it moves into the dialog, and what the pointer is on is told the
|
|
61
|
+
* pointer left, so a tooltip on the element that opened the dialog closes as it would have without `inert`.
|
|
62
|
+
*
|
|
63
|
+
* A part that is inert of its own, as Vuetify keeps a closed modal drawer or side sheet, is left alone, and only the
|
|
64
|
+
* parts this made inert are made live again. What a part's owner sets its `inert` to while this holds it, as a drawer
|
|
65
|
+
* that closes behind the dialog does (a narrower window, a link in the dialog), is the part's again once the dialogs
|
|
66
|
+
* close.
|
|
61
67
|
*
|
|
62
68
|
* It watches the document for Vuetify's overlays, so it sees every dialog, whoever renders it, without a dialog
|
|
63
69
|
* component of its own. The page is live again as soon as the render that closes or unmounts its dialog ends, before
|
|
@@ -72,6 +78,8 @@ function useShellInertBehindDialog() {
|
|
|
72
78
|
const open = new Map();
|
|
73
79
|
/** @type {Set<HTMLElement>} the dialogs this made inert under the one on top */
|
|
74
80
|
const inertDialogs = new Set();
|
|
81
|
+
/** @type {Map<HTMLElement, { inert: boolean }>} the parts of the page this made inert, each with its owner's inert */
|
|
82
|
+
const heldParts = new Map();
|
|
75
83
|
/** @type {EventTarget | null} */
|
|
76
84
|
let focused = null;
|
|
77
85
|
/** @type {EventTarget | null} */
|
|
@@ -101,11 +109,81 @@ function useShellInertBehindDialog() {
|
|
|
101
109
|
return element;
|
|
102
110
|
}
|
|
103
111
|
|
|
104
|
-
/**
|
|
112
|
+
/**
|
|
113
|
+
* Before `parts` turn inert under the top dialog: focus in one of them moves into that dialog, and each element in
|
|
114
|
+
* them under the pointer is told the pointer left. Neither happens by itself. The browser moves focus out of an
|
|
115
|
+
* element that turns inert to the body, with no element named as where it went, which Vuetify's activators take as
|
|
116
|
+
* focus staying where it was; and it sends no mouseleave to an inert element, however the pointer moves. A tooltip
|
|
117
|
+
* (or a menu opened on hover) on the element that opened the dialog would stay open behind it until the dialog
|
|
118
|
+
* closed.
|
|
119
|
+
* @param {HTMLElement[]} parts
|
|
120
|
+
* @param {HTMLElement | undefined} top
|
|
121
|
+
*/
|
|
122
|
+
function leave(parts, top) {
|
|
123
|
+
if (parts.length === 0 || !top) {
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
const active = document.activeElement;
|
|
127
|
+
if (active && parts.some((part) => part.contains(active))) {
|
|
128
|
+
/** @type {HTMLElement | null} */ (top.querySelector(".v-overlay__content"))?.focus({ preventScroll: true });
|
|
129
|
+
}
|
|
130
|
+
for (const part of parts) {
|
|
131
|
+
for (const hovered of part.querySelectorAll(":hover")) {
|
|
132
|
+
hovered.dispatchEvent(new MouseEvent("mouseleave"));
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* Makes a live part of the page inert and keeps aside what its owner sets its `inert` to until `release`. Vue sets
|
|
139
|
+
* `inert` only when the owner's own value changes (Vuetify's drawer has `inert` while it is closed), so a drawer that
|
|
140
|
+
* closes while it is held sets it once, here, and that value must outlast this hold: forgetting it would leave the
|
|
141
|
+
* closed drawer live after the dialog.
|
|
142
|
+
* @param {HTMLElement} part
|
|
143
|
+
*/
|
|
144
|
+
function hold(part) {
|
|
145
|
+
const inert = /** @type {PropertyDescriptor} */ (Object.getOwnPropertyDescriptor(HTMLElement.prototype, "inert"));
|
|
146
|
+
if (!heldParts.has(part)) {
|
|
147
|
+
const own = { inert: false };
|
|
148
|
+
Object.defineProperty(part, "inert", {
|
|
149
|
+
configurable: true,
|
|
150
|
+
get: () => inert.get?.call(part),
|
|
151
|
+
set: (value) => {
|
|
152
|
+
own.inert = Boolean(value);
|
|
153
|
+
}
|
|
154
|
+
});
|
|
155
|
+
heldParts.set(part, own);
|
|
156
|
+
}
|
|
157
|
+
inert.set?.call(part, true);
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* Gives a held part its own `inert` back: live, unless its owner made it inert meanwhile.
|
|
162
|
+
* @param {HTMLElement} part
|
|
163
|
+
*/
|
|
164
|
+
function release(part) {
|
|
165
|
+
const own = heldParts.get(part);
|
|
166
|
+
heldParts.delete(part);
|
|
167
|
+
Reflect.deleteProperty(part, "inert");
|
|
168
|
+
part.inert = Boolean(own?.inert);
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* While dialogs are open, every live part of the page is held inert; once none is, the parts this holds are released.
|
|
173
|
+
* A part inert of its own is never touched.
|
|
174
|
+
* @param {boolean} inert
|
|
175
|
+
*/
|
|
105
176
|
function setPageInert(inert) {
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
part.inert
|
|
177
|
+
if (inert) {
|
|
178
|
+
for (const part of document.querySelectorAll(SHELL_PAGE)) {
|
|
179
|
+
if (part instanceof HTMLElement && !part.inert) {
|
|
180
|
+
hold(part);
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
for (const part of [...heldParts.keys()]) {
|
|
185
|
+
if (!inert || !part.isConnected) {
|
|
186
|
+
release(part);
|
|
109
187
|
}
|
|
110
188
|
}
|
|
111
189
|
}
|
|
@@ -153,6 +231,8 @@ function useShellInertBehindDialog() {
|
|
|
153
231
|
inertDialogs.delete(dialog);
|
|
154
232
|
}
|
|
155
233
|
}
|
|
234
|
+
const page = dialogs.length > 0 ? [...document.querySelectorAll(SHELL_PAGE)] : [];
|
|
235
|
+
leave([...page, ...lower].filter((part) => part instanceof HTMLElement && !part.inert), top);
|
|
156
236
|
for (const dialog of lower) {
|
|
157
237
|
if (!dialog.inert) {
|
|
158
238
|
dialog.inert = true;
|
|
@@ -1917,3 +1917,66 @@ test("segmented buttons, filter chips, fixed tabs, menus and dialog actions take
|
|
|
1917
1917
|
await stopProcess(vite);
|
|
1918
1918
|
}
|
|
1919
1919
|
});
|
|
1920
|
+
|
|
1921
|
+
// A rail label wraps only between words, to two lines at most, as Material 3's rail labels do: a word wider than the
|
|
1922
|
+
// rail ends in an ellipsis instead of breaking in two, and a label that needs a third line ends its second in one.
|
|
1923
|
+
test("rail labels wrap only between words, and a word wider than the rail ends in an ellipsis, at the rail's default and a narrow width", {
|
|
1924
|
+
skip: RUN_BROWSER_TEST ? false : "set JSKIT_SHELL_WEB_BROWSER_INTEGRATION=1",
|
|
1925
|
+
timeout: 90_000
|
|
1926
|
+
}, async (t) => {
|
|
1927
|
+
const { vite, browser } = await startFixture(t);
|
|
1928
|
+
const page = await browser.newPage({ baseURL: vite.baseURL, viewport: { width: 768, height: 1024 } });
|
|
1929
|
+
for (const railWidth of [80, 56]) {
|
|
1930
|
+
await page.goto(`/w/acme/admin/bookings?theme=light&railWidth=${railWidth}`);
|
|
1931
|
+
const rail = page.getByTestId("jskit-shell-rail");
|
|
1932
|
+
const labels = rail.locator(".shell-menu-link-item__rail-label");
|
|
1933
|
+
await expect(labels.first()).toBeVisible();
|
|
1934
|
+
await expect.poll(async () => Math.round((await rail.boundingBox())?.width || 0)).toBe(railWidth);
|
|
1935
|
+
// A label as the rail lays it out: its lines, the words that lie on two of them, the words wider than the label's
|
|
1936
|
+
// room, whether it ends in an ellipsis, and whether it stays inside the rail.
|
|
1937
|
+
const layout = (text) => labels.nth(1).evaluate(async (element, label) => {
|
|
1938
|
+
element.textContent = label;
|
|
1939
|
+
await document.fonts.ready;
|
|
1940
|
+
const style = window.getComputedStyle(element);
|
|
1941
|
+
const box = element.getBoundingClientRect();
|
|
1942
|
+
const railBox = element.closest("[data-testid=jskit-shell-rail]").getBoundingClientRect();
|
|
1943
|
+
const split = [];
|
|
1944
|
+
const tooWide = [];
|
|
1945
|
+
for (const match of label.matchAll(/\S+/gu)) {
|
|
1946
|
+
const range = document.createRange();
|
|
1947
|
+
range.setStart(element.firstChild, match.index);
|
|
1948
|
+
range.setEnd(element.firstChild, match.index + match[0].length);
|
|
1949
|
+
const rects = [...range.getClientRects()].filter((rect) => rect.width > 0);
|
|
1950
|
+
if (new Set(rects.map((rect) => Math.round(rect.top))).size > 1) {
|
|
1951
|
+
split.push(match[0]);
|
|
1952
|
+
}
|
|
1953
|
+
if (range.getBoundingClientRect().width > element.clientWidth + 0.5) {
|
|
1954
|
+
tooWide.push(match[0]);
|
|
1955
|
+
}
|
|
1956
|
+
}
|
|
1957
|
+
return {
|
|
1958
|
+
lines: Math.round(box.height / Number.parseFloat(style.lineHeight)),
|
|
1959
|
+
split,
|
|
1960
|
+
tooWide,
|
|
1961
|
+
ellipsis: style.textOverflow === "ellipsis" &&
|
|
1962
|
+
(element.scrollWidth > element.clientWidth + 0.5 || element.scrollHeight > element.clientHeight + 0.5),
|
|
1963
|
+
inside: box.left >= railBox.left - 0.5 && box.right <= railBox.right + 0.5
|
|
1964
|
+
};
|
|
1965
|
+
}, text);
|
|
1966
|
+
const at = `at a ${railWidth}px rail`;
|
|
1967
|
+
assert.deepEqual(await layout("Home"), { lines: 1, split: [], tooWide: [], ellipsis: false, inside: true }, `a short word ${at}`);
|
|
1968
|
+
assert.deepEqual(await layout("Administration"), { lines: 1, split: [], tooWide: ["Administration"], ellipsis: true, inside: true }, `one word wider than the rail ${at}`);
|
|
1969
|
+
// Two words, each on its own line; one wider than the rail ends in an ellipsis.
|
|
1970
|
+
const twoWords = await layout("Race Engineer");
|
|
1971
|
+
assert.deepEqual(twoWords, { lines: 2, split: [], tooWide: twoWords.tooWide, ellipsis: twoWords.tooWide.length > 0, inside: true }, `two words ${at}`);
|
|
1972
|
+
if (railWidth === 80) {
|
|
1973
|
+
assert.deepEqual(twoWords.tooWide, [], "both words fit the default rail");
|
|
1974
|
+
}
|
|
1975
|
+
const after = await layout("Supplier Administration");
|
|
1976
|
+
assert.ok(after.tooWide.includes("Administration"), `"Administration" is wider than the rail ${at}`);
|
|
1977
|
+
assert.deepEqual({ ...after, tooWide: [] }, { lines: 2, split: [], tooWide: [], ellipsis: true, inside: true }, `a word wider than the rail after another ${at}`);
|
|
1978
|
+
const long = await layout("Quarterly performance and planning");
|
|
1979
|
+
assert.deepEqual({ ...long, tooWide: [] }, { lines: 2, split: [], tooWide: [], ellipsis: true, inside: true }, `a label that needs three lines ${at}`);
|
|
1980
|
+
}
|
|
1981
|
+
await page.close();
|
|
1982
|
+
});
|
|
@@ -42,17 +42,23 @@ async function activate(locator) {
|
|
|
42
42
|
await locator.press("Enter");
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
-
// The parts of the page ShellLayout makes inert, and whether
|
|
45
|
+
// The parts of the page ShellLayout makes inert: whether each is, and whether it is a closed modal drawer or side
|
|
46
|
+
// sheet, which Vuetify keeps inert of its own.
|
|
46
47
|
function readPageParts(page) {
|
|
47
|
-
return page.evaluate(() => [...document.querySelectorAll("[data-shell-page]")].map((part) =>
|
|
48
|
+
return page.evaluate(() => [...document.querySelectorAll("[data-shell-page]")].map((part) => ({
|
|
49
|
+
inert: part.inert,
|
|
50
|
+
closedDrawer: part.classList.contains("v-navigation-drawer--temporary") &&
|
|
51
|
+
!part.classList.contains("v-navigation-drawer--active")
|
|
52
|
+
})));
|
|
48
53
|
}
|
|
49
54
|
|
|
50
|
-
// Every part of the page, the app bar, the navigation and main at least, inert or else live
|
|
55
|
+
// Every part of the page, the app bar, the navigation and main at least, inert, or else live but for a closed modal
|
|
56
|
+
// drawer or side sheet, which stays inert.
|
|
51
57
|
async function expectPageInert(page, inert, message) {
|
|
52
58
|
await expect.poll(async () => {
|
|
53
59
|
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);
|
|
60
|
+
return parts.length >= 3 && parts.every((part) => part.inert === (inert || part.closedDrawer));
|
|
61
|
+
}, { message: `${message}: every part of the page ${inert ? "inert" : "live, a closed drawer inert"}` }).toBe(true);
|
|
56
62
|
}
|
|
57
63
|
|
|
58
64
|
// Whether `locator`'s element takes focus when asked, as a keyboard and assistive technology ask.
|
|
@@ -260,3 +266,121 @@ test("Vuetify's activator gets focus back, the shell's own error dialog makes th
|
|
|
260
266
|
assert.equal(await takesFocus(page.locator("main a[href]").first()), true, "the next page takes focus");
|
|
261
267
|
await page.close();
|
|
262
268
|
});
|
|
269
|
+
|
|
270
|
+
test("a tooltip open on what opens a dialog closes as the dialog opens, whether the keyboard or the pointer opened it, from the page and from a dialog under another", {
|
|
271
|
+
skip: SKIP,
|
|
272
|
+
timeout: 120_000
|
|
273
|
+
}, async (t) => {
|
|
274
|
+
const page = await openNotes(t, EXPANDED);
|
|
275
|
+
const tooltip = page.getByRole("tooltip");
|
|
276
|
+
const archive = page.getByTestId("fixture-note-archive");
|
|
277
|
+
const archiveDialog = page.getByTestId("fixture-archive-dialog");
|
|
278
|
+
|
|
279
|
+
// By keyboard: Tab onto Archive note shows its tooltip, Enter opens the dialog, and the tooltip goes with the keyboard.
|
|
280
|
+
await page.getByTestId("fixture-note-link").focus();
|
|
281
|
+
await page.keyboard.press("Tab");
|
|
282
|
+
await expect(archive).toBeFocused();
|
|
283
|
+
await expect(tooltip.filter({ hasText: "Archive note" })).toBeVisible();
|
|
284
|
+
await page.keyboard.press("Enter");
|
|
285
|
+
await expectDialogOpen(page, archiveDialog);
|
|
286
|
+
await expect(tooltip).toHaveCount(0);
|
|
287
|
+
await activate(page.getByTestId("fixture-archive-cancel"));
|
|
288
|
+
await expect(archiveDialog).toBeHidden();
|
|
289
|
+
await expect(archive).toBeFocused();
|
|
290
|
+
|
|
291
|
+
// By pointer: the pointer on Archive note shows its tooltip, a click opens the dialog, and once the pointer moves on
|
|
292
|
+
// the tooltip has gone, as when the page stays live.
|
|
293
|
+
await page.getByTestId("fixture-note-edit").focus();
|
|
294
|
+
await archive.hover();
|
|
295
|
+
await expect(tooltip.filter({ hasText: "Archive note" })).toBeVisible();
|
|
296
|
+
await archive.click();
|
|
297
|
+
await expectDialogOpen(page, archiveDialog);
|
|
298
|
+
await page.mouse.move(1, 1);
|
|
299
|
+
await expect(tooltip).toHaveCount(0);
|
|
300
|
+
await activate(page.getByTestId("fixture-archive-cancel"));
|
|
301
|
+
await expect(archiveDialog).toBeHidden();
|
|
302
|
+
|
|
303
|
+
// From a dialog: Remove access's tooltip goes as the second dialog opens over the first, which turns inert.
|
|
304
|
+
await activate(page.getByTestId("fixture-invite"));
|
|
305
|
+
const inviteDialog = page.getByTestId("fixture-invite-dialog");
|
|
306
|
+
await expectDialogOpen(page, inviteDialog);
|
|
307
|
+
const remove = page.getByTestId("fixture-invite-remove");
|
|
308
|
+
await remove.hover();
|
|
309
|
+
await expect(tooltip.filter({ hasText: "Asks before removing" })).toBeVisible();
|
|
310
|
+
await remove.click();
|
|
311
|
+
const removeDialog = page.getByTestId("fixture-remove-dialog");
|
|
312
|
+
await expectDialogOpen(page, removeDialog);
|
|
313
|
+
await page.mouse.move(1, 1);
|
|
314
|
+
await expect(tooltip).toHaveCount(0);
|
|
315
|
+
await activate(page.getByTestId("fixture-remove-keep"));
|
|
316
|
+
await expect(removeDialog).toBeHidden();
|
|
317
|
+
await expect(remove).toBeFocused();
|
|
318
|
+
await page.keyboard.press("Escape");
|
|
319
|
+
await expect(inviteDialog).toBeHidden();
|
|
320
|
+
await page.close();
|
|
321
|
+
});
|
|
322
|
+
|
|
323
|
+
test("a closed modal drawer stays inert after a dialog, and a drawer that closes or opens behind a dialog is as it is once the dialog closes", {
|
|
324
|
+
skip: SKIP,
|
|
325
|
+
timeout: 120_000
|
|
326
|
+
}, async (t) => {
|
|
327
|
+
const page = await openNotes(t, COMPACT);
|
|
328
|
+
const drawer = page.getByTestId("jskit-shell-drawer");
|
|
329
|
+
const help = drawer.getByRole("link", { name: "Help and support" });
|
|
330
|
+
const drawerInert = () => drawer.evaluate((element) => element.inert);
|
|
331
|
+
const dialog = page.getByTestId("fixture-invite-dialog");
|
|
332
|
+
const modal = () => expect(drawer).toHaveClass(/v-navigation-drawer--temporary/u);
|
|
333
|
+
const standard = () => expect(drawer).not.toHaveClass(/v-navigation-drawer--temporary/u);
|
|
334
|
+
assert.equal(await drawerInert(), true, "the closed modal drawer is inert");
|
|
335
|
+
|
|
336
|
+
// A dialog opens and closes over the page: the closed drawer stays inert, out of the keyboard's and assistive
|
|
337
|
+
// technology's reach, while the rest of the page is live again.
|
|
338
|
+
await activate(buttonOf(page.getByTestId("fixture-invite")));
|
|
339
|
+
await expectDialogOpen(page, dialog);
|
|
340
|
+
await expectPageInert(page, true, "with the dialog open");
|
|
341
|
+
await activate(page.getByTestId("fixture-invite-cancel"));
|
|
342
|
+
await expect(dialog).toBeHidden();
|
|
343
|
+
await expectPageInert(page, false, "after the dialog closes");
|
|
344
|
+
assert.equal(await drawerInert(), true, "the closed drawer is inert after the dialog");
|
|
345
|
+
assert.equal(await takesFocus(help), false, "the closed drawer's destination takes no focus");
|
|
346
|
+
assert.equal((await readAccessibleNames(page)).has("Help and support"), false, "assistive technology skips the closed drawer");
|
|
347
|
+
|
|
348
|
+
// The menu control still opens it, live, and Escape closes it, inert again.
|
|
349
|
+
await activate(page.getByTestId("jskit-shell-nav-toggle"));
|
|
350
|
+
await expect.poll(drawerInert, { message: "the open drawer is live" }).toBe(false);
|
|
351
|
+
assert.equal(await takesFocus(help), true, "the open drawer's destination takes focus");
|
|
352
|
+
await page.keyboard.press("Escape");
|
|
353
|
+
await expect.poll(drawerInert, { message: "the drawer closed by Escape is inert" }).toBe(true);
|
|
354
|
+
|
|
355
|
+
// On an expanded window the standard drawer is live. Behind a dialog it is inert, and when the window narrows it
|
|
356
|
+
// closes there, as a modal drawer: once the dialog closes it is the closed drawer it became, inert.
|
|
357
|
+
await page.setViewportSize(EXPANDED);
|
|
358
|
+
await standard();
|
|
359
|
+
await expect.poll(drawerInert, { message: "the standard drawer is live" }).toBe(false);
|
|
360
|
+
await activate(page.getByTestId("fixture-invite"));
|
|
361
|
+
await expectDialogOpen(page, dialog);
|
|
362
|
+
await expectPageInert(page, true, "with the dialog open on an expanded window");
|
|
363
|
+
await page.setViewportSize(COMPACT);
|
|
364
|
+
await modal();
|
|
365
|
+
await expectPageInert(page, true, "with the dialog open once the window narrowed");
|
|
366
|
+
await activate(page.getByTestId("fixture-invite-cancel"));
|
|
367
|
+
await expect(dialog).toBeHidden();
|
|
368
|
+
await expectPageInert(page, false, "after the dialog over the drawer that closed behind it");
|
|
369
|
+
assert.equal(await drawerInert(), true, "the drawer that closed behind the dialog is inert");
|
|
370
|
+
assert.equal(await takesFocus(help), false, "its destination takes no focus");
|
|
371
|
+
|
|
372
|
+
// The other way: the closed modal drawer opens as the standard drawer when the window widens behind a dialog. It is
|
|
373
|
+
// inert while the dialog is open and live once it closes.
|
|
374
|
+
await activate(buttonOf(page.getByTestId("fixture-invite")));
|
|
375
|
+
await expectDialogOpen(page, dialog);
|
|
376
|
+
await page.setViewportSize(EXPANDED);
|
|
377
|
+
await standard();
|
|
378
|
+
await expectPageInert(page, true, "with the dialog open once the window widened");
|
|
379
|
+
assert.equal(await takesFocus(help), false, "the drawer that opened behind the dialog takes no focus");
|
|
380
|
+
await activate(page.getByTestId("fixture-invite-cancel"));
|
|
381
|
+
await expect(dialog).toBeHidden();
|
|
382
|
+
await expectPageInert(page, false, "after the dialog over the drawer that opened behind it");
|
|
383
|
+
assert.equal(await drawerInert(), false, "the standard drawer is live");
|
|
384
|
+
assert.equal(await takesFocus(help), true, "its destination takes focus");
|
|
385
|
+
await page.close();
|
|
386
|
+
});
|