@jskit-ai/shell-web 0.2.34 → 0.2.36

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,7 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ - 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.
5
6
  - 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.
6
7
  - A message showing over a dialog no longer takes Escape and the browser's Back from it: the snackbar stays out of Vuetify's overlay stack (`_disable-global-stack`), as Vuetify's tooltips do, so Escape and Back close the dialog under it. This uses a private Vuetify prop until Vuetify leaves snackbars off the stack itself (reported as https://github.com/vuetifyjs/vuetify/issues/23392).
7
8
  - The "Test copy" banner has no accessible label any more: it is a note read by its visible "Test copy", with "Test copy: emails, messages and payments are simulated, not sent." as its `aria-description`. The label made it a labelled element, so an application's browser test looking up its Email field with Playwright's inexact `page.getByLabel("Email")` found the banner too and failed strict mode.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jskit-ai/shell-web",
3
- "version": "0.2.34",
3
+ "version": "0.2.36",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "test": "jskit test"
@@ -46,14 +46,14 @@
46
46
  "./locales/en.json": "./locales/en.json"
47
47
  },
48
48
  "dependencies": {
49
- "@jskit-ai/architecture-inspector": "0.1.23"
49
+ "@jskit-ai/architecture-inspector": "0.1.24"
50
50
  },
51
51
  "devDependencies": {
52
- "@jskit-ai/material-web": "0.1.6",
52
+ "@jskit-ai/material-web": "0.1.7",
53
53
  "@vue/compiler-sfc": "3.5.44"
54
54
  },
55
55
  "peerDependencies": {
56
- "@jskit-ai/kernel": "0.2.25",
56
+ "@jskit-ai/kernel": "0.2.26",
57
57
  "pinia": "^4.0.3",
58
58
  "vue": "^3.5.44",
59
59
  "vue-router": "^5.3.1",
@@ -260,6 +260,9 @@ onBeforeUnmount(() => {
260
260
  <span class="shell-layout__pull-refresh-label">{{ pullRefreshLabel }}</span>
261
261
  </div>
262
262
 
263
+ <!-- Material 3 runs the rail and the standard drawer the window's full height beside the top app bar, so they come
264
+ before it in the layout (order -1) and their menu control shares the page title's row. A modal drawer comes first
265
+ of all (order -2): it opens from the window's edge over the rail and the app bar. -->
263
266
  <v-navigation-drawer
264
267
  v-if="showsMediumRail"
265
268
  class="shell-layout__rail"
@@ -268,6 +271,7 @@ onBeforeUnmount(() => {
268
271
  :style="navigationStyle"
269
272
  permanent
270
273
  rail
274
+ :order="-1"
271
275
  :rail-width="resolvedRailWidth"
272
276
  color="surface"
273
277
  >
@@ -292,7 +296,6 @@ onBeforeUnmount(() => {
292
296
  </ShellNavigationScope>
293
297
  </v-navigation-drawer>
294
298
 
295
- <!-- A modal drawer is the outermost layout item, so it opens from the window's edge over the rail and app bar. -->
296
299
  <v-navigation-drawer
297
300
  v-if="hasDrawer"
298
301
  id="jskit-shell-drawer"
@@ -309,7 +312,7 @@ onBeforeUnmount(() => {
309
312
  :color="modalLayout ? 'surface-container-low' : 'surface'"
310
313
  :temporary="modalLayout"
311
314
  :permanent="!modalLayout"
312
- :order="modalLayout ? -1 : 0"
315
+ :order="modalLayout ? -2 : -1"
313
316
  :width="resolvedDrawerWidth"
314
317
  :rail="drawerPresentation.rail"
315
318
  :rail-width="resolvedRailWidth"
@@ -490,13 +493,14 @@ onBeforeUnmount(() => {
490
493
  border: 0;
491
494
  }
492
495
 
496
+ /* The menu control's row is the top app bar's (64dp), so it sits beside the page title and the destinations start
497
+ right below it. */
493
498
  .shell-layout__rail-header,
494
499
  .shell-layout__drawer-header {
495
500
  align-items: center;
496
501
  display: flex;
497
502
  gap: 4px;
498
- min-height: 56px;
499
- padding-block: 4px;
503
+ min-height: 64px;
500
504
  }
501
505
 
502
506
  .shell-layout__rail-header,
@@ -238,6 +238,63 @@ async function readNavigationIconCenters(drawer, expect) {
238
238
  return centers;
239
239
  }
240
240
 
241
+ // Material 3 runs the navigation rail and the standard drawer the window's full height beside the top app bar, never
242
+ // under it: their menu control sits in the page title's row and their destinations start right below that row, after
243
+ // the identity (a workspace switcher) when the drawer shows one. Lists what differs; nothing when the layout is right.
244
+ function readNavigationBesideAppBar(navigation) {
245
+ return navigation.evaluate((element) => {
246
+ const box = (node) => {
247
+ const rect = node?.getBoundingClientRect();
248
+ return rect && rect.width > 0 && rect.height > 0 ? rect : null;
249
+ };
250
+ const px = (value) => `${Math.round(value * 10) / 10}px`;
251
+ const centre = (rect) => rect.top + rect.height / 2;
252
+ const appBar = box(document.querySelector("[data-testid=jskit-shell-app-bar]"));
253
+ const title = box(document.querySelector("[data-testid=jskit-shell-app-bar] [data-testid=jskit-shell-page-title]"));
254
+ const toggle = box(element.querySelector("[data-testid=jskit-shell-nav-toggle]"));
255
+ const identity = box(element.querySelector(".shell-layout__identity"));
256
+ const destination = box(element.querySelector("a.shell-menu-link-item[href]"));
257
+ const missing = Object.entries({ appBar, title, toggle, destination })
258
+ .filter(([, rect]) => !rect)
259
+ .map(([name]) => `no visible ${name}`);
260
+ if (missing.length > 0) {
261
+ return missing;
262
+ }
263
+ const problems = [];
264
+ const navigationBox = element.getBoundingClientRect();
265
+ const below = navigationBox.top - appBar.top;
266
+ if (Math.abs(below) > 1) {
267
+ problems.push(`the navigation starts ${px(below)} below the top app bar's top instead of beside it`);
268
+ }
269
+ const overlap = Math.min(navigationBox.right, appBar.right) - Math.max(navigationBox.left, appBar.left);
270
+ if (overlap > 1) {
271
+ problems.push(`the top app bar spans ${px(overlap)} of the navigation's width`);
272
+ }
273
+ const offset = centre(toggle) - centre(title);
274
+ if (Math.abs(offset) > 1) {
275
+ problems.push(`the menu control's centre is ${px(offset)} from the page title's`);
276
+ }
277
+ const rows = identity
278
+ ? [["identity", identity, appBar.bottom], ["first destination", destination, identity.bottom]]
279
+ : [["first destination", destination, appBar.bottom]];
280
+ for (const [name, rect, rowEnd] of rows) {
281
+ const gap = rect.top - rowEnd;
282
+ if (Math.abs(gap) > 1) {
283
+ problems.push(`the ${name} starts ${px(gap)} below the row above it`);
284
+ }
285
+ }
286
+ return problems;
287
+ });
288
+ }
289
+
290
+ async function expectNavigationBesideAppBar(navigation, expect) {
291
+ const presentation = await navigation.getAttribute("data-presentation");
292
+ await expect.poll(() => readNavigationBesideAppBar(navigation), {
293
+ message: `The ${presentation || "navigation"} must run the window's full height beside the top app bar, its menu ` +
294
+ "control in the page title's row and its destinations right below it."
295
+ }).toEqual([]);
296
+ }
297
+
241
298
  function isRequestedOrDescendantLocation(actualUrl, targetUrl) {
242
299
  const normalizePathname = (value) => {
243
300
  const pathname = String(value || "/");
@@ -376,6 +433,7 @@ async function runAdaptiveShellSmokeCase({
376
433
  await expect(rail).toBeVisible();
377
434
  await expectElementVisibility(page, expect, "jskit-shell-drawer", false);
378
435
  await expectDrawerWidth(rail, expect, drawer, "data-rail-width");
436
+ await expectNavigationBesideAppBar(rail, expect);
379
437
  await toggle.click();
380
438
  await expect(drawer).toHaveAttribute("data-presentation", "modal");
381
439
  await expectElementVisibility(page, expect, "jskit-shell-drawer", true);
@@ -393,6 +451,7 @@ async function runAdaptiveShellSmokeCase({
393
451
  }
394
452
  await expect(drawer).toHaveAttribute("data-presentation", "drawer");
395
453
  await expectDrawerWidth(drawer, expect, drawer, "data-drawer-width");
454
+ await expectNavigationBesideAppBar(drawer, expect);
396
455
  await expectContentAwareDrawerFit(drawer, expect);
397
456
  const expandedIconCenters = await readNavigationIconCenters(drawer, expect);
398
457
  await page.keyboard.press("Escape");
@@ -401,6 +460,7 @@ async function runAdaptiveShellSmokeCase({
401
460
  await toggle.click();
402
461
  await expect(drawer).toHaveAttribute("data-presentation", "rail");
403
462
  await expectDrawerWidth(drawer, expect, drawer, "data-rail-width");
463
+ await expectNavigationBesideAppBar(drawer, expect);
404
464
  await expectCentredRailNavigation(page, drawer, expect, expandedIconCenters);
405
465
  await expectNoHorizontalOverflow(page, expect);
406
466
  }
@@ -427,6 +487,7 @@ function runAdaptiveShellSmoke({
427
487
 
428
488
  export {
429
489
  DEFAULT_VIEWPORTS,
490
+ expectNavigationBesideAppBar,
430
491
  isRequestedOrDescendantLocation,
431
492
  runAdaptiveShellSmoke,
432
493
  runAdaptiveShellSmokeCase
@@ -12,6 +12,7 @@ import {
12
12
  import { materialSymbols } from "@jskit-ai/material-web/client/symbols";
13
13
  import {
14
14
  DEFAULT_VIEWPORTS,
15
+ expectNavigationBesideAppBar,
15
16
  runAdaptiveShellSmokeCase
16
17
  } from "../src/test/adaptiveShellSmoke.js";
17
18
  import { pressShellBack, shellBackButton, shellPageTitle } from "../src/test/shellNavigation.js";
@@ -321,6 +322,59 @@ test("the shared smoke case passes a phone shell whose destinations are all in t
321
322
  await page.close();
322
323
  });
323
324
 
325
+ // Material 3 runs the rail and the standard drawer the window's full height beside the top app bar: their menu control
326
+ // shares the page title's row, the destinations start right below it, and an inner page keeps its Up arrow in the bar.
327
+ // A phone keeps its navigation bar and its modal drawer, opened from the app bar over everything.
328
+ test("the rail and the drawer run the window's full height beside the top app bar, their menu control in the title's row", {
329
+ skip: RUN_BROWSER_TEST ? false : "set JSKIT_SHELL_WEB_BROWSER_INTEGRATION=1",
330
+ timeout: 120_000
331
+ }, async (t) => {
332
+ const { vite, browser } = await startFixture(t);
333
+ const page = await browser.newPage({ baseURL: vite.baseURL, viewport: { width: 1280, height: 900 } });
334
+ const appBar = page.getByTestId("jskit-shell-app-bar");
335
+ const drawer = page.getByTestId("jskit-shell-drawer");
336
+ const toggle = page.getByTestId("jskit-shell-nav-toggle");
337
+
338
+ await page.goto("/home");
339
+ await expect(drawer).toHaveAttribute("data-presentation", "drawer");
340
+ await expectNavigationBesideAppBar(drawer, expect);
341
+ await toggle.click();
342
+ await expect(drawer).toHaveAttribute("data-presentation", "rail");
343
+ await expectNavigationBesideAppBar(drawer, expect);
344
+
345
+ // An identity at the drawer's top (a workspace switcher) takes the row under the title's, the destinations the next.
346
+ await page.goto("/home?identity=Northwind");
347
+ await expect(drawer).toHaveAttribute("data-presentation", "drawer");
348
+ await expect(drawer.getByRole("button", { name: "Northwind" })).toBeVisible();
349
+ await expectNavigationBesideAppBar(drawer, expect);
350
+
351
+ await page.goto("/home/contacts/ada");
352
+ await expect(shellPageTitle(page)).toHaveText("Ada Lovelace");
353
+ await expect(appBar.getByTestId("jskit-shell-back")).toBeVisible();
354
+ await expectNavigationBesideAppBar(drawer, expect);
355
+
356
+ await page.setViewportSize({ width: 768, height: 1024 });
357
+ await page.goto("/home");
358
+ await expectNavigationBesideAppBar(page.getByTestId("jskit-shell-rail"), expect);
359
+
360
+ await page.setViewportSize({ width: 390, height: 844 });
361
+ await page.goto("/home");
362
+ await expect(page.getByTestId("jskit-shell-bottom-nav")).toBeVisible();
363
+ await expect(drawer).toHaveAttribute("data-presentation", "modal");
364
+ await expect(appBar.getByTestId("jskit-shell-nav-toggle")).toBeVisible();
365
+ assert.deepEqual(await appBar.boundingBox(), { x: 0, y: 0, width: 390, height: 64 });
366
+ await toggle.click();
367
+ await expect.poll(async () => {
368
+ const box = await drawer.boundingBox();
369
+ // What the window shows at the bar's leading corner once the drawer is open: the drawer, over the app bar.
370
+ const onTop = await page.evaluate(() => Boolean(document.elementFromPoint(8, 32)?.closest("[data-testid=jskit-shell-drawer]")));
371
+ return { x: box?.x, y: box?.y, onTop };
372
+ }).toEqual({ x: 0, y: 0, onTop: true });
373
+ await page.keyboard.press("Escape");
374
+ await expect(toggle).toBeFocused();
375
+ await page.close();
376
+ });
377
+
324
378
  test("shell-web preserves the active form across responsive changes", {
325
379
  skip: RUN_BROWSER_TEST ? false : "set JSKIT_SHELL_WEB_BROWSER_INTEGRATION=1",
326
380
  timeout: 90_000