@jskit-ai/shell-web 0.2.40 → 0.2.41

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.
@@ -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. Presses of the note's Edit and the dialogs' actions are counted.
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">Remove access</v-btn>
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jskit-ai/shell-web",
3
- "version": "0.2.40",
3
+ "version": "0.2.41",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "test": "jskit test"
@@ -57,7 +57,8 @@ 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`.
61
62
  *
62
63
  * It watches the document for Vuetify's overlays, so it sees every dialog, whoever renders it, without a dialog
63
64
  * component of its own. The page is live again as soon as the render that closes or unmounts its dialog ends, before
@@ -101,6 +102,31 @@ function useShellInertBehindDialog() {
101
102
  return element;
102
103
  }
103
104
 
105
+ /**
106
+ * Before `parts` turn inert under the top dialog: focus in one of them moves into that dialog, and each element in
107
+ * them under the pointer is told the pointer left. Neither happens by itself. The browser moves focus out of an
108
+ * element that turns inert to the body, with no element named as where it went, which Vuetify's activators take as
109
+ * focus staying where it was; and it sends no mouseleave to an inert element, however the pointer moves. A tooltip
110
+ * (or a menu opened on hover) on the element that opened the dialog would stay open behind it until the dialog
111
+ * closed.
112
+ * @param {HTMLElement[]} parts
113
+ * @param {HTMLElement | undefined} top
114
+ */
115
+ function leave(parts, top) {
116
+ if (parts.length === 0 || !top) {
117
+ return;
118
+ }
119
+ const active = document.activeElement;
120
+ if (active && parts.some((part) => part.contains(active))) {
121
+ /** @type {HTMLElement | null} */ (top.querySelector(".v-overlay__content"))?.focus({ preventScroll: true });
122
+ }
123
+ for (const part of parts) {
124
+ for (const hovered of part.querySelectorAll(":hover")) {
125
+ hovered.dispatchEvent(new MouseEvent("mouseleave"));
126
+ }
127
+ }
128
+ }
129
+
104
130
  /** @param {boolean} inert */
105
131
  function setPageInert(inert) {
106
132
  for (const part of document.querySelectorAll(SHELL_PAGE)) {
@@ -153,6 +179,8 @@ function useShellInertBehindDialog() {
153
179
  inertDialogs.delete(dialog);
154
180
  }
155
181
  }
182
+ const page = dialogs.length > 0 ? [...document.querySelectorAll(SHELL_PAGE)] : [];
183
+ leave([...page, ...lower].filter((part) => part instanceof HTMLElement && !part.inert), top);
156
184
  for (const dialog of lower) {
157
185
  if (!dialog.inert) {
158
186
  dialog.inert = true;
@@ -260,3 +260,56 @@ test("Vuetify's activator gets focus back, the shell's own error dialog makes th
260
260
  assert.equal(await takesFocus(page.locator("main a[href]").first()), true, "the next page takes focus");
261
261
  await page.close();
262
262
  });
263
+
264
+ 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", {
265
+ skip: SKIP,
266
+ timeout: 120_000
267
+ }, async (t) => {
268
+ const page = await openNotes(t, EXPANDED);
269
+ const tooltip = page.getByRole("tooltip");
270
+ const archive = page.getByTestId("fixture-note-archive");
271
+ const archiveDialog = page.getByTestId("fixture-archive-dialog");
272
+
273
+ // By keyboard: Tab onto Archive note shows its tooltip, Enter opens the dialog, and the tooltip goes with the keyboard.
274
+ await page.getByTestId("fixture-note-link").focus();
275
+ await page.keyboard.press("Tab");
276
+ await expect(archive).toBeFocused();
277
+ await expect(tooltip.filter({ hasText: "Archive note" })).toBeVisible();
278
+ await page.keyboard.press("Enter");
279
+ await expectDialogOpen(page, archiveDialog);
280
+ await expect(tooltip).toHaveCount(0);
281
+ await activate(page.getByTestId("fixture-archive-cancel"));
282
+ await expect(archiveDialog).toBeHidden();
283
+ await expect(archive).toBeFocused();
284
+
285
+ // By pointer: the pointer on Archive note shows its tooltip, a click opens the dialog, and once the pointer moves on
286
+ // the tooltip has gone, as when the page stays live.
287
+ await page.getByTestId("fixture-note-edit").focus();
288
+ await archive.hover();
289
+ await expect(tooltip.filter({ hasText: "Archive note" })).toBeVisible();
290
+ await archive.click();
291
+ await expectDialogOpen(page, archiveDialog);
292
+ await page.mouse.move(1, 1);
293
+ await expect(tooltip).toHaveCount(0);
294
+ await activate(page.getByTestId("fixture-archive-cancel"));
295
+ await expect(archiveDialog).toBeHidden();
296
+
297
+ // From a dialog: Remove access's tooltip goes as the second dialog opens over the first, which turns inert.
298
+ await activate(page.getByTestId("fixture-invite"));
299
+ const inviteDialog = page.getByTestId("fixture-invite-dialog");
300
+ await expectDialogOpen(page, inviteDialog);
301
+ const remove = page.getByTestId("fixture-invite-remove");
302
+ await remove.hover();
303
+ await expect(tooltip.filter({ hasText: "Asks before removing" })).toBeVisible();
304
+ await remove.click();
305
+ const removeDialog = page.getByTestId("fixture-remove-dialog");
306
+ await expectDialogOpen(page, removeDialog);
307
+ await page.mouse.move(1, 1);
308
+ await expect(tooltip).toHaveCount(0);
309
+ await activate(page.getByTestId("fixture-remove-keep"));
310
+ await expect(removeDialog).toBeHidden();
311
+ await expect(remove).toBeFocused();
312
+ await page.keyboard.press("Escape");
313
+ await expect(inviteDialog).toBeHidden();
314
+ await page.close();
315
+ });