@jskit-ai/shell-web 0.2.38 → 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 CHANGED
@@ -2,6 +2,10 @@
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.
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.
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.
5
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.
6
10
  - The navigation rail and the standard drawer run the window's full height beside the top app bar, as Material 3 draws them: their menu control sits in the page title's row and the first destination starts right below it. The app bar spanned the window's width and the rail or drawer started under it, adding a 56dp row of its own for the menu control, so the control sat under the title and the destinations started two rows down. They now come before the app bar in the layout (`order` -1, and -2 for the modal drawer, which still opens from the window's edge over the rail and the app bar), and their header is the app bar's 64dp. An inner page keeps its Up arrow in the app bar beside them. Compact windows are unchanged (navigation bar, modal drawer). `runAdaptiveShellSmokeCase` checks it on medium and expanded windows, and `expectNavigationBesideAppBar(navigation, expect)` is exported for a test of its own.
7
11
  - On a compact window (under 600 px), a message that shows while a dialog, a bottom sheet or a temporary navigation drawer is open sits at the top of the window, clear of the actions it reports on; it keeps that place until it closes. Elsewhere and on wider windows messages stay at the bottom start.
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>
@@ -0,0 +1,51 @@
1
+ <script setup>
2
+ import { reactive } from "vue";
3
+ import ShellPageAction from "../../../src/client/components/ShellPageAction.vue";
4
+ import ShellPageActions from "../../../src/client/components/ShellPageActions.vue";
5
+ import ShellPrimaryAction from "../../../src/client/components/ShellPrimaryAction.vue";
6
+
7
+ // Actions whose work runs until the test settles it: a page action that is `pending`, the primary page action with
8
+ // `loading` (Vuetify's progress indicator) and the screen's primary action (a FAB on compact windows) that is `pending`.
9
+ // Each press is counted, and `globalThis.settleFixtureAction(name)` ends that action's run.
10
+ const running = reactive({ sync: false, save: false, send: false });
11
+ const presses = reactive({ sync: 0, save: 0, send: 0 });
12
+
13
+ function start(name) {
14
+ presses[name] += 1;
15
+ running[name] = true;
16
+ }
17
+
18
+ globalThis.settleFixtureAction = (name) => {
19
+ running[name] = false;
20
+ };
21
+ </script>
22
+
23
+ <template>
24
+ <section class="pa-4">
25
+ <ShellPageActions>
26
+ <ShellPageAction
27
+ icon="$refresh"
28
+ :label="running.sync ? 'Syncing…' : 'Sync'"
29
+ :pending="running.sync"
30
+ data-testid="fixture-pending-sync"
31
+ @click="start('sync')"
32
+ />
33
+ <ShellPageAction
34
+ primary
35
+ icon="$check"
36
+ label="Save"
37
+ :loading="running.save"
38
+ data-testid="fixture-pending-save"
39
+ @click="start('save')"
40
+ />
41
+ </ShellPageActions>
42
+ <ShellPrimaryAction
43
+ icon="$send"
44
+ :label="running.send ? 'Sending…' : 'Send'"
45
+ :pending="running.send"
46
+ data-testid="fixture-pending-send"
47
+ @click="start('send')"
48
+ />
49
+ <p data-testid="fixture-pending-presses">sync={{ presses.sync }} save={{ presses.save }} send={{ presses.send }}</p>
50
+ </section>
51
+ </template>
@@ -0,0 +1,57 @@
1
+ <script setup>
2
+ import { ref } from "vue";
3
+ import { vPending } from "../../../src/client/directives/vPending.js";
4
+
5
+ // A dialog's action with v-pending, in the dialog's form: Send invite runs until the test settles it, accepted
6
+ // (`globalThis.settleFixtureInvite()`) or refused with a field marked: Email (`settleFixtureInvite("Already invited.")`)
7
+ // or the Plan radio group, whose first choice, the current plan, is disabled (`settleFixtureInvite(message, "plan")`).
8
+ const dialog = ref(false);
9
+ const sending = ref(false);
10
+ const presses = ref(0);
11
+ const name = ref("");
12
+ const email = ref("");
13
+ const emailError = ref("");
14
+ const plan = ref("current");
15
+ const planError = ref("");
16
+
17
+ function invite() {
18
+ presses.value += 1;
19
+ emailError.value = "";
20
+ planError.value = "";
21
+ sending.value = true;
22
+ }
23
+
24
+ globalThis.settleFixtureInvite = (refusal = "", field = "email") => {
25
+ emailError.value = field === "email" ? refusal : "";
26
+ planError.value = field === "plan" ? refusal : "";
27
+ sending.value = false;
28
+ };
29
+ </script>
30
+
31
+ <template>
32
+ <section class="pa-4">
33
+ <v-btn variant="text" data-testid="fixture-open-invite" @click="dialog = true">Invite someone</v-btn>
34
+ <p data-testid="fixture-invite-presses">{{ presses }}</p>
35
+ <v-dialog v-model="dialog" max-width="480">
36
+ <v-card title="Invite someone">
37
+ <v-form @submit.prevent="invite">
38
+ <v-card-text>
39
+ <v-text-field v-model="name" label="Name" />
40
+ <v-text-field v-model="email" label="Email" :error-messages="emailError" />
41
+ <v-radio-group v-model="plan" label="Plan" :error-messages="planError">
42
+ <v-radio label="Current plan" value="current" disabled />
43
+ <v-radio label="Larger plan" value="larger" />
44
+ </v-radio-group>
45
+ </v-card-text>
46
+ <v-card-actions>
47
+ <v-spacer />
48
+ <v-btn variant="text" @click="dialog = false">Cancel</v-btn>
49
+ <v-btn v-pending="sending" type="submit" variant="text" data-testid="fixture-send-invite">
50
+ {{ sending ? "Sending…" : "Send invite" }}
51
+ </v-btn>
52
+ </v-card-actions>
53
+ </v-form>
54
+ </v-card>
55
+ </v-dialog>
56
+ </section>
57
+ </template>
@@ -18,6 +18,8 @@ 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";
22
+ import PendingActionsPage from "./PendingActionsPage.vue";
21
23
  import DialogFeedbackPage from "./DialogFeedbackPage.vue";
22
24
  import ReportsPage from "./ReportsPage.vue";
23
25
  import ScreenPage from "./ScreenPage.vue";
@@ -341,7 +343,11 @@ const routes = [
341
343
  { path: "/home/components", component: ComponentsPage, meta: { jskit: { title: "Components" } } },
342
344
  { path: "/home/actions", component: ActionsPage, meta: { jskit: { title: "Actions" } } },
343
345
  { path: "/home/actions/new", component: ActionsFormPage, meta: { jskit: { title: "New entry", parent: "/actions" } } },
346
+ // Actions whose work the test holds, to check they keep keyboard focus while it runs.
347
+ { path: "/home/pending", component: PendingActionsPage, meta: { jskit: { title: "Pending actions" } } },
348
+ { path: "/home/pending-dialog", component: () => import("./PendingDialogPage.vue"), meta: { jskit: { title: "Invites" } } },
344
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" } } },
345
351
  { path: "/home/studio", component: StudioPage, meta: { ownBar: true, jskit: { title: "Studio" } } },
346
352
  { path: "/home/studio/:id", component: StudioPage, meta: { ownBar: true, jskit: { parent: "/studio" } } },
347
353
  { path: "/home/:section?", component: ScreenPage, meta: { title: "Home surface" } },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jskit-ai/shell-web",
3
- "version": "0.2.38",
3
+ "version": "0.2.40",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "test": "jskit test"
@@ -38,6 +38,7 @@
38
38
  "./client/composables/useShellPageTitle": "./src/client/composables/useShellPageTitle.js",
39
39
  "./client/composables/useShellPageClose": "./src/client/composables/useShellPageClose.js",
40
40
  "./client/composables/useShellWindowSizeClass": "./src/client/composables/useShellWindowSizeClass.js",
41
+ "./client/directives/vPending": "./src/client/directives/vPending.js",
41
42
  "./client/providers/ShellWebClientProvider": "./src/client/providers/ShellWebClientProvider.js",
42
43
  "./client/types": "./src/client/types.js",
43
44
  "./test/adaptiveShellSmoke": "./src/test/adaptiveShellSmoke.js",
@@ -49,7 +50,7 @@
49
50
  "@jskit-ai/architecture-inspector": "0.1.25"
50
51
  },
51
52
  "devDependencies": {
52
- "@jskit-ai/material-web": "0.1.8",
53
+ "@jskit-ai/material-web": "0.1.9",
53
54
  "@vue/compiler-sfc": "3.5.44"
54
55
  },
55
56
  "peerDependencies": {
@@ -100,6 +101,7 @@
100
101
  "@jskit-ai/shell-web/client/composables/useShellPageClose",
101
102
  "@jskit-ai/shell-web/client/composables/useShellPageTitle",
102
103
  "@jskit-ai/shell-web/client/composables/useShellWindowSizeClass",
104
+ "@jskit-ai/shell-web/client/directives/vPending",
103
105
  "@jskit-ai/shell-web/client/types"
104
106
  ],
105
107
  "exclude": [
@@ -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"
@@ -351,14 +359,15 @@ onBeforeUnmount(() => {
351
359
  target="shell-layout:primary-menu"
352
360
  default
353
361
  />
354
- <v-divider class="shell-layout__drawer-divider" />
362
+ <!-- A list holds only list items (WCAG 1.3.1), so the divider between the two groups is presentational. -->
363
+ <v-divider class="shell-layout__drawer-divider" role="presentation" />
355
364
  <ShellOutlet target="shell-layout:secondary-menu" />
356
365
  </v-list>
357
366
  </ShellNavigationScope>
358
367
  </slot>
359
368
  </v-navigation-drawer>
360
369
 
361
- <v-main class="bg-background">
370
+ <v-main class="bg-background" data-shell-page>
362
371
  <div class="shell-layout__content" :class="{ 'shell-layout__content--compact': isCompactLayout }">
363
372
  <ShellRouteTransition>
364
373
  <slot />
@@ -369,6 +378,7 @@ onBeforeUnmount(() => {
369
378
  <v-bottom-navigation
370
379
  v-if="showsBottomNavigation"
371
380
  class="shell-layout__bottom-nav"
381
+ data-shell-page
372
382
  data-testid="jskit-shell-bottom-nav"
373
383
  bg-color="surface-container"
374
384
  :elevation="0"
@@ -400,6 +410,7 @@ onBeforeUnmount(() => {
400
410
  v-if="!isCompactLayout"
401
411
  :model-value="supportingContentOpen"
402
412
  class="shell-layout__supporting-side-sheet"
413
+ data-shell-page
403
414
  color="surface-container-low"
404
415
  temporary
405
416
  location="right"
@@ -4,14 +4,20 @@ import { useLink } from "vue-router";
4
4
  import {
5
5
  NO_SHELL_NAVIGATION_PRESENTATION,
6
6
  NO_VUETIFY_ICONS,
7
+ NO_VUETIFY_LIST,
7
8
  SHELL_NAVIGATION_PRESENTATION_KEY,
8
9
  VUETIFY_ICONS_KEY,
10
+ VUETIFY_LIST_KEY,
9
11
  filledIconAlias
10
12
  } from "../support/navigationPresentation.js";
11
13
  import { activateShellNavigationLinkOnSpace } from "../support/navigationLinkKeyboard.js";
12
14
 
13
15
  // One navigation destination as Material 3 draws it where it sits: a drawer item (a 56dp pill), a rail item (icon in a
14
- // 56x32 indicator with its label below) or a list item. The active destination's icon is filled.
16
+ // 56x32 indicator with its label below) or a list item. The active destination's icon is filled. In a list (the
17
+ // drawer's, the rail's, a settings section's) it is a list item holding its link: Vuetify makes the item itself the
18
+ // link, and a list holds only list items (WCAG 1.3.1). Attributes land on the link.
19
+ defineOptions({ inheritAttrs: false });
20
+
15
21
  const props = defineProps({
16
22
  label: {
17
23
  type: String,
@@ -49,38 +55,61 @@ const active = computed(() =>
49
55
  );
50
56
  const displayIcon = computed(() => (active.value ? filledIconAlias(props.icon, iconOptions.aliases) : props.icon));
51
57
  const rail = computed(() => presentation.value === "rail");
58
+ /** @type {object | null} */
59
+ const list = inject(VUETIFY_LIST_KEY, NO_VUETIFY_LIST);
60
+ // Vuetify gives an item in a list the role "link" when it links somewhere, and "listitem" when it doesn't.
61
+ const listItem = computed(() => Boolean(list && props.href));
62
+
63
+ // What holds an item outside a list: nothing, the link stands alone.
64
+ const Unwrapped = (_props, { slots }) => slots.default();
65
+ Unwrapped.inheritAttrs = false;
52
66
  </script>
53
67
 
54
68
  <template>
55
- <v-list-item
56
- v-if="rail"
57
- class="shell-menu-link-item shell-menu-link-item--rail"
58
- :to="props.sameOrigin ? props.href : undefined"
59
- :href="props.sameOrigin ? undefined : props.href"
60
- :active="active"
61
- :disabled="props.disabled"
62
- :ripple="false"
63
- @keydown.space="activateShellNavigationLinkOnSpace"
69
+ <component
70
+ :is="listItem ? 'div' : Unwrapped"
71
+ :role="listItem ? 'listitem' : undefined"
72
+ :class="listItem ? ['shell-navigation-item', { 'shell-navigation-item--rail': rail }] : undefined"
64
73
  >
65
- <span class="shell-menu-link-item__indicator">
66
- <v-icon v-if="displayIcon" :icon="displayIcon" />
67
- </span>
68
- <span class="shell-menu-link-item__rail-label">{{ props.label }}</span>
69
- </v-list-item>
70
- <v-list-item
71
- v-else
72
- class="shell-menu-link-item"
73
- :title="props.label"
74
- :to="props.sameOrigin ? props.href : undefined"
75
- :href="props.sameOrigin ? undefined : props.href"
76
- :prepend-icon="displayIcon || undefined"
77
- :active="active"
78
- :disabled="props.disabled"
79
- @keydown.space="activateShellNavigationLinkOnSpace"
80
- />
74
+ <v-list-item
75
+ v-if="rail"
76
+ class="shell-menu-link-item shell-menu-link-item--rail"
77
+ :to="props.sameOrigin ? props.href : undefined"
78
+ :href="props.sameOrigin ? undefined : props.href"
79
+ :active="active"
80
+ :disabled="props.disabled"
81
+ :ripple="false"
82
+ v-bind="$attrs"
83
+ @keydown.space="activateShellNavigationLinkOnSpace"
84
+ >
85
+ <span class="shell-menu-link-item__indicator">
86
+ <v-icon v-if="displayIcon" :icon="displayIcon" />
87
+ </span>
88
+ <span class="shell-menu-link-item__rail-label">{{ props.label }}</span>
89
+ </v-list-item>
90
+ <v-list-item
91
+ v-else
92
+ class="shell-menu-link-item"
93
+ :title="props.label"
94
+ :to="props.sameOrigin ? props.href : undefined"
95
+ :href="props.sameOrigin ? undefined : props.href"
96
+ :prepend-icon="displayIcon || undefined"
97
+ :active="active"
98
+ :disabled="props.disabled"
99
+ v-bind="$attrs"
100
+ @keydown.space="activateShellNavigationLinkOnSpace"
101
+ />
102
+ </component>
81
103
  </template>
82
104
 
83
105
  <style scoped>
106
+ /* A nav list spaces each item but its first 4dp below the one before (Vuetify's `.v-list--nav
107
+ .v-list-item:not(:first-child)`). In its list item the item is always a first child, so the list item keeps that
108
+ spacing; the rail spaces its destinations itself. */
109
+ .v-list--nav .shell-navigation-item:not(.shell-navigation-item--rail, :first-child) {
110
+ margin-top: 4px;
111
+ }
112
+
84
113
  .shell-menu-link-item {
85
114
  --v-activated-opacity: 0;
86
115
  border-radius: 9999px;
@@ -2,6 +2,7 @@
2
2
  import { computed, inject, mergeProps, onBeforeUnmount, onMounted, ref, useAttrs, useId } from "vue";
3
3
  import { useShellWindowSizeClass } from "../composables/useShellWindowSizeClass.js";
4
4
  import { useJskitText } from "../i18n.js";
5
+ import { vPending } from "../directives/vPending.js";
5
6
  import { NO_SHELL_PAGE_ACTIONS_REGISTRY, SHELL_PAGE_ACTIONS_REGISTRY_KEY } from "../support/pageActions.js";
6
7
 
7
8
  // One page action in the top app bar. On compact windows a secondary action shows as an icon button named by its
@@ -10,6 +11,10 @@ import { NO_SHELL_PAGE_ACTIONS_REGISTRY, SHELL_PAGE_ACTIONS_REGISTRY_KEY } from
10
11
  // overflow menu, and on compact windows every action but the primary one joins it.
11
12
  // Attributes such as `type="submit"` and `form` (so an app bar Save can submit the page's form), `target`,
12
13
  // `data-testid` or `aria-*` land on the button, or on the menu item, in every form.
14
+ // While its action runs (`pending`, or `loading` with Vuetify's progress indicator in place of the label) the button
15
+ // keeps keyboard focus: it reads as unavailable and ignores activation until the action settles (v-pending), and it is
16
+ // never `disabled` meanwhile, so a `disabled` that also covers the running state (such as `addEdit.isSubmitDisabled`)
17
+ // keeps focus too.
13
18
  defineOptions({ inheritAttrs: false });
14
19
 
15
20
  const props = defineProps({
@@ -59,6 +64,11 @@ const props = defineProps({
59
64
  type: Boolean,
60
65
  default: false
61
66
  },
67
+ // The action is running: give it a pending label, such as "Saving…".
68
+ pending: {
69
+ type: Boolean,
70
+ default: false
71
+ },
62
72
  loading: {
63
73
  type: Boolean,
64
74
  default: false
@@ -72,6 +82,8 @@ const { isCompact } = useShellWindowSizeClass();
72
82
  const resolvedLabel = computed(() => text(props.label));
73
83
  const iconOnly = computed(() => Boolean(props.icon) && isCompact.value && !props.primary);
74
84
  const color = computed(() => props.color || (props.primary ? "primary" : "on-surface-variant"));
85
+ const pending = computed(() => props.pending || props.loading);
86
+ const disabled = computed(() => props.disabled && !pending.value);
75
87
  // A boolean `download` is the attribute without a file name.
76
88
  const download = computed(() => (props.download === true ? "" : props.download || undefined));
77
89
 
@@ -95,7 +107,8 @@ const entry = {
95
107
  color: props.color,
96
108
  primary: props.primary,
97
109
  overflow: props.overflow,
98
- disabled: props.disabled,
110
+ disabled: disabled.value,
111
+ pending: pending.value,
99
112
  loading: props.loading
100
113
  })),
101
114
  attrs,
@@ -123,6 +136,7 @@ onBeforeUnmount(() => {
123
136
  <template #activator="{ props: tooltipProps }">
124
137
  <v-btn
125
138
  v-bind="mergeProps(attrs, tooltipProps)"
139
+ v-pending="pending"
126
140
  class="shell-page-action"
127
141
  :icon="props.icon"
128
142
  variant="text"
@@ -131,7 +145,7 @@ onBeforeUnmount(() => {
131
145
  :replace="props.replace"
132
146
  :href="props.href"
133
147
  :download="download"
134
- :disabled="props.disabled"
148
+ :disabled="disabled"
135
149
  :loading="props.loading"
136
150
  :aria-label="resolvedLabel"
137
151
  @click="handleClick"
@@ -141,6 +155,7 @@ onBeforeUnmount(() => {
141
155
  <v-btn
142
156
  v-else
143
157
  v-bind="attrs"
158
+ v-pending="pending"
144
159
  class="shell-page-action shell-page-action--labelled"
145
160
  :variant="props.primary ? 'flat' : 'text'"
146
161
  :color="color"
@@ -149,7 +164,7 @@ onBeforeUnmount(() => {
149
164
  :replace="props.replace"
150
165
  :href="props.href"
151
166
  :download="download"
152
- :disabled="props.disabled"
167
+ :disabled="disabled"
153
168
  :loading="props.loading"
154
169
  @click="handleClick"
155
170
  >
@@ -45,7 +45,7 @@ watch(showsMenu, (shows) => {
45
45
  // A menu item's props: the action's own attributes, then its label, icon, colour, link or download, and state.
46
46
  function itemProps(entry) {
47
47
  const state = entry.state.value;
48
- const unavailable = Boolean(state.disabled || state.loading);
48
+ const unavailable = Boolean(state.disabled || state.pending);
49
49
  return mergeProps(entry.attrs, {
50
50
  title: state.label,
51
51
  prependIcon: state.icon || undefined,