@jskit-ai/shell-web 0.2.48 → 0.2.50
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 +1 -0
- package/README.md +11 -0
- package/package.json +4 -4
- package/patterns/application-shell/PATTERN.md +5 -3
- package/src/client/components/ShellErrorHost.vue +50 -39
- package/src/client/composables/useShellErrorHost.js +42 -9
- package/src/client/error/presentation.js +6 -17
- package/test/adaptiveShell.browser.test.js +23 -2
- package/test/errorActions.test.js +13 -1
- package/test/errorPresentation.test.js +4 -10
- package/test/useShellErrorHost.test.js +47 -3
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
## Unreleased
|
|
4
4
|
|
|
5
|
+
- `ShellErrorHost`'s banners no longer cover the page below a top app bar. They floated there over the top of the content, fixed and up to 1,120 px wide, and reserved no room, so on every page with an app bar a request recovery banner hid the content's first lines and took their clicks (Playwright: `.shell-error-host__banner` intercepts pointer events). They are now a top Vuetify layout item (`v-layout-item`) of their own measured height, placed after the app bar and the navigation, so `v-main` starts the content below them as it starts it below the app bar, and gives the room back when they close; content scrolled under them passes under them as under the app bar. On a surface without an app bar (sign-in) they still join the page flow above the content and publish `--shell-error-banners-inline-height`, as before. They keep their z-index (2600) and their look. An app that draws its own layout around `v-main` gets the same room, since Vuetify's layout reserves it.
|
|
5
6
|
- The environment banner of a staging page that real people use (its server has `STAGING_REACHES_REAL_PEOPLE=true`, so the page carries the kernel's `jskit-staging-reaches-real-people` tag) reads "Staging · real people", described as "Staging that real people use: email and text messages reach the people they are for, other messages are logged and payments use the sandbox.", in place of the test-copy wording; `installAppEnvironmentBanner` takes `reachesRealPeople`, read from the page when omitted. New message keys: `jskit.shell.appEnvironment.stagingRealPeople` and `stagingRealPeopleDescription`. Every other page's banner is unchanged.
|
|
6
7
|
- 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").
|
|
7
8
|
- 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.
|
package/README.md
CHANGED
|
@@ -24,6 +24,17 @@ 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
|
+
Its banners never cover the content either: below a top app bar they are a top
|
|
28
|
+
layout item of their own height, so `v-main` starts the content below them,
|
|
29
|
+
and on a surface without an app bar they join the page flow above it.
|
|
30
|
+
|
|
31
|
+
Request recovery reports a network failure of a `GET` or `HEAD` query as a
|
|
32
|
+
banner with Retry, for reads whose screen does not show the failure itself.
|
|
33
|
+
`useList()`, `useView()` and `useAddEdit()` from `@jskit-ai/http-web` show
|
|
34
|
+
theirs where the read failed (`loadError`, with Retry), so their queries are
|
|
35
|
+
left out unless the caller passes `requestRecovery`. A hand-written query
|
|
36
|
+
whose component shows its own load error with Retry sets
|
|
37
|
+
`meta: { jskit: { requestRecovery: false } }`, so the failure shows once.
|
|
27
38
|
|
|
28
39
|
## The page behind a dialog
|
|
29
40
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jskit-ai/shell-web",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.50",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"test": "jskit test"
|
|
@@ -47,14 +47,14 @@
|
|
|
47
47
|
"./locales/en.json": "./locales/en.json"
|
|
48
48
|
},
|
|
49
49
|
"dependencies": {
|
|
50
|
-
"@jskit-ai/architecture-inspector": "0.1.
|
|
50
|
+
"@jskit-ai/architecture-inspector": "0.1.32"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
|
-
"@jskit-ai/material-web": "0.1.
|
|
53
|
+
"@jskit-ai/material-web": "0.1.10",
|
|
54
54
|
"@vue/compiler-sfc": "3.5.44"
|
|
55
55
|
},
|
|
56
56
|
"peerDependencies": {
|
|
57
|
-
"@jskit-ai/kernel": "0.2.
|
|
57
|
+
"@jskit-ai/kernel": "0.2.33",
|
|
58
58
|
"pinia": "^4.0.3",
|
|
59
59
|
"vue": "^3.5.44",
|
|
60
60
|
"vue-router": "^5.3.1",
|
|
@@ -38,9 +38,11 @@ placement registry, topology, and adaptive smoke helper exported by
|
|
|
38
38
|
- Cached route/resource state hydrates writable UI state synchronously or with
|
|
39
39
|
immediate watchers.
|
|
40
40
|
- Loading uses stable skeletons, not spinners or shifting status banners.
|
|
41
|
-
- `ShellErrorHost` stays directly inside `v-app`.
|
|
42
|
-
|
|
43
|
-
|
|
41
|
+
- `ShellErrorHost` stays directly inside `v-app`. Below a top app bar its
|
|
42
|
+
banners are a top Vuetify layout item of their own height, so `v-main`
|
|
43
|
+
starts the content below them as it starts it below the app bar; on a
|
|
44
|
+
surface without one (such as sign-in) they join the page flow above the
|
|
45
|
+
content. Either way they never cover it. A full-viewport fixed screen on
|
|
44
46
|
such a surface starts at `var(--shell-error-banners-inline-height, 0px)`, as
|
|
45
47
|
`@jskit-ai/auth-web`'s login and reset views do.
|
|
46
48
|
- Restyle shell chrome through its custom properties, not by overriding
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
<script setup>
|
|
2
|
+
import { VLayoutItem } from "vuetify/components/VLayout";
|
|
2
3
|
import { useShellErrorHost } from "../composables/useShellErrorHost.js";
|
|
3
4
|
import {
|
|
4
5
|
actionsFor,
|
|
@@ -13,6 +14,7 @@ import { useJskitText } from "../i18n.js";
|
|
|
13
14
|
const { t, text, serverMessage } = useJskitText();
|
|
14
15
|
const {
|
|
15
16
|
bannerEntries,
|
|
17
|
+
bannerLayoutItemProps,
|
|
16
18
|
bannerPlacement,
|
|
17
19
|
bannersElement,
|
|
18
20
|
dialogEntry,
|
|
@@ -33,45 +35,52 @@ const {
|
|
|
33
35
|
:class="{ 'shell-error-host--inline-banners': bannerPlacement.inline }"
|
|
34
36
|
aria-live="polite"
|
|
35
37
|
>
|
|
36
|
-
|
|
38
|
+
<!-- Below a top app bar the banners are a top layout item of their own height, so the layout starts the page's
|
|
39
|
+
content below them as it starts it below the app bar; without one they are a block in the page flow. -->
|
|
40
|
+
<component
|
|
41
|
+
:is="bannerPlacement.inline ? 'div' : VLayoutItem"
|
|
37
42
|
v-if="bannerEntries.length > 0"
|
|
38
|
-
|
|
39
|
-
class="shell-error-host__banners"
|
|
40
|
-
:class="{ 'shell-error-host__banners--inline': bannerPlacement.inline }"
|
|
41
|
-
:style="bannerPlacement.style"
|
|
42
|
-
data-testid="shell-error-host-banners"
|
|
43
|
+
v-bind="bannerPlacement.inline ? {} : bannerLayoutItemProps"
|
|
44
|
+
class="shell-error-host__banners-place"
|
|
43
45
|
>
|
|
44
|
-
<div
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
46
|
+
<div
|
|
47
|
+
ref="bannersElement"
|
|
48
|
+
class="shell-error-host__banners"
|
|
49
|
+
:class="{ 'shell-error-host__banners--inline': bannerPlacement.inline }"
|
|
50
|
+
data-testid="shell-error-host-banners"
|
|
51
|
+
>
|
|
52
|
+
<div class="shell-error-host__banner-stack">
|
|
53
|
+
<v-alert
|
|
54
|
+
v-for="entry in bannerEntries"
|
|
55
|
+
:key="entry.id"
|
|
56
|
+
:color="`${resolveSeverityColor(entry.severity)}-container`"
|
|
57
|
+
:icon="resolveSeverityIcon(entry.severity)"
|
|
58
|
+
variant="flat"
|
|
59
|
+
density="comfortable"
|
|
60
|
+
:rounded="12"
|
|
61
|
+
class="shell-error-host__banner"
|
|
62
|
+
closable
|
|
63
|
+
:close-label="t('jskit.shell.actions.close')"
|
|
64
|
+
@click:close="dismiss(entry)"
|
|
65
|
+
>
|
|
66
|
+
<div class="d-flex align-center ga-3 flex-wrap">
|
|
67
|
+
<span>{{ serverMessage(entry) }}</span>
|
|
68
|
+
<v-spacer />
|
|
69
|
+
<v-btn
|
|
70
|
+
v-for="(action, index) in actionsFor(entry)"
|
|
71
|
+
:key="index"
|
|
72
|
+
variant="text"
|
|
73
|
+
size="small"
|
|
74
|
+
class="text-none"
|
|
75
|
+
@click="runAction(entry, action)"
|
|
76
|
+
>
|
|
77
|
+
{{ text(action.label) }}
|
|
78
|
+
</v-btn>
|
|
79
|
+
</div>
|
|
80
|
+
</v-alert>
|
|
81
|
+
</div>
|
|
73
82
|
</div>
|
|
74
|
-
</
|
|
83
|
+
</component>
|
|
75
84
|
|
|
76
85
|
<!-- Material 3 keeps a snackbar clear of the actions it reports on. Vuetify places it inside the layout, above the
|
|
77
86
|
navigation bar and a FAB that takes layout room (`<v-fab app layout>`). On a phone it is centred there; on
|
|
@@ -154,16 +163,18 @@ const {
|
|
|
154
163
|
order: -1;
|
|
155
164
|
}
|
|
156
165
|
|
|
166
|
+
/* The floating banners' layout item spans the content's width under the app bar and takes no clicks itself. */
|
|
167
|
+
.shell-error-host__banners-place {
|
|
168
|
+
pointer-events: none;
|
|
169
|
+
}
|
|
170
|
+
|
|
157
171
|
.shell-error-host__banners {
|
|
158
|
-
position: fixed;
|
|
159
|
-
z-index: 2600;
|
|
160
172
|
pointer-events: none;
|
|
161
173
|
padding: 10px 12px;
|
|
162
174
|
}
|
|
163
175
|
|
|
164
176
|
.shell-error-host__banners--inline {
|
|
165
177
|
position: relative;
|
|
166
|
-
z-index: auto;
|
|
167
178
|
padding-top: calc(env(safe-area-inset-top, 0px) + 10px);
|
|
168
179
|
}
|
|
169
180
|
|
|
@@ -7,6 +7,13 @@ import { useJskitText } from "../i18n.js";
|
|
|
7
7
|
import { useShellWindowSizeClass } from "./useShellWindowSizeClass.js";
|
|
8
8
|
|
|
9
9
|
const BANNER_INLINE_HEIGHT_PROPERTY = "--shell-error-banners-inline-height";
|
|
10
|
+
// The name of the top layout item floating banners take below the app bar, and its order: after every default-order
|
|
11
|
+
// item (the app bar, the navigation rail or drawer), so the banners sit under the app bar and beside the navigation,
|
|
12
|
+
// over the content's own width, whatever order the app mounts them in.
|
|
13
|
+
const BANNER_LAYOUT_ITEM_NAME = "shell-error-host-banners";
|
|
14
|
+
const BANNER_LAYOUT_ITEM_ORDER = 1;
|
|
15
|
+
// Above Vuetify's overlays (2400), as the banners always were.
|
|
16
|
+
const BANNER_Z_INDEX = 2600;
|
|
10
17
|
// The modal surfaces that keep their actions at their bottom edge on a compact window, where the snackbar shows: an
|
|
11
18
|
// open dialog (a bottom sheet is one) and an open temporary navigation drawer.
|
|
12
19
|
const MODAL_SURFACE_SELECTOR = [
|
|
@@ -32,8 +39,9 @@ function publishInlineBannerHeight(height = 0) {
|
|
|
32
39
|
}
|
|
33
40
|
|
|
34
41
|
/**
|
|
35
|
-
* What the error host shows and does: the snackbar queue, the dialog, and where the banners sit.
|
|
36
|
-
* their height so
|
|
42
|
+
* What the error host shows and does: the snackbar queue, the dialog, and where the banners sit. Below a top app bar the
|
|
43
|
+
* banners take a top layout item of their own measured height, so the page's content starts below them; without one
|
|
44
|
+
* they join the page flow and publish their height so full-viewport surfaces can start below them.
|
|
37
45
|
*/
|
|
38
46
|
function useShellErrorHost() {
|
|
39
47
|
const runtime = useShellWebErrorRuntime();
|
|
@@ -44,30 +52,54 @@ function useShellErrorHost() {
|
|
|
44
52
|
const bannerEntries = computed(() => store.channels.banner || []);
|
|
45
53
|
const dialogEntry = computed(() => store.channels.dialog[0] || null);
|
|
46
54
|
const displayedSnackbarEntry = ref(null);
|
|
47
|
-
const
|
|
55
|
+
const layout = useLayout();
|
|
48
56
|
|
|
49
57
|
const bannersElement = ref(null);
|
|
50
|
-
|
|
58
|
+
// The floating banners' measured height: the room their layout item takes below the app bar.
|
|
59
|
+
const bannerHeight = ref(0);
|
|
60
|
+
// Where the banners start: under the top app bar, which mainRect's top is. Once they float, the layout counts their
|
|
61
|
+
// own room in mainRect too, so their layout item says where they start.
|
|
62
|
+
const bannerTop = computed(() => {
|
|
63
|
+
const item = layout.getLayoutItem(BANNER_LAYOUT_ITEM_NAME);
|
|
64
|
+
return item ? item.top : layout.mainRect.value.top;
|
|
65
|
+
});
|
|
66
|
+
const bannerPlacement = computed(() => resolveBannerPlacement(bannerTop.value));
|
|
67
|
+
// The floating banners' VLayoutItem.
|
|
68
|
+
const bannerLayoutItemProps = computed(() => ({
|
|
69
|
+
name: BANNER_LAYOUT_ITEM_NAME,
|
|
70
|
+
order: BANNER_LAYOUT_ITEM_ORDER,
|
|
71
|
+
position: "top",
|
|
72
|
+
size: bannerHeight.value,
|
|
73
|
+
modelValue: true,
|
|
74
|
+
style: { zIndex: BANNER_Z_INDEX }
|
|
75
|
+
}));
|
|
51
76
|
let bannerResizeObserver = null;
|
|
52
77
|
|
|
53
78
|
function stopObservingBanners() {
|
|
54
79
|
bannerResizeObserver?.disconnect();
|
|
55
80
|
bannerResizeObserver = null;
|
|
56
81
|
publishInlineBannerHeight(0);
|
|
82
|
+
bannerHeight.value = 0;
|
|
57
83
|
}
|
|
58
84
|
|
|
59
85
|
watch(
|
|
60
86
|
[bannersElement, () => bannerPlacement.value.inline],
|
|
61
87
|
([element, inline]) => {
|
|
62
88
|
stopObservingBanners();
|
|
63
|
-
if (!element
|
|
89
|
+
if (!element) {
|
|
64
90
|
return;
|
|
65
91
|
}
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
92
|
+
const measure = () => {
|
|
93
|
+
const height = element.getBoundingClientRect().height;
|
|
94
|
+
if (inline) {
|
|
95
|
+
publishInlineBannerHeight(height);
|
|
96
|
+
} else {
|
|
97
|
+
bannerHeight.value = Math.ceil(height);
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
bannerResizeObserver = new ResizeObserver(measure);
|
|
69
101
|
bannerResizeObserver.observe(element);
|
|
70
|
-
|
|
102
|
+
measure();
|
|
71
103
|
},
|
|
72
104
|
{ flush: "post" }
|
|
73
105
|
);
|
|
@@ -175,6 +207,7 @@ function useShellErrorHost() {
|
|
|
175
207
|
|
|
176
208
|
return {
|
|
177
209
|
bannerEntries,
|
|
210
|
+
bannerLayoutItemProps,
|
|
178
211
|
bannerPlacement,
|
|
179
212
|
bannersElement,
|
|
180
213
|
dialogEntry,
|
|
@@ -37,23 +37,12 @@ function actionsFor(entry) {
|
|
|
37
37
|
return entry ? [entry.action, ...entry.additionalActions].filter(Boolean) : [];
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
// Banners
|
|
41
|
-
//
|
|
42
|
-
// content instead
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
return { inline: true, style: undefined };
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
return {
|
|
50
|
-
inline: false,
|
|
51
|
-
style: {
|
|
52
|
-
top: `calc(env(safe-area-inset-top, 0px) + ${top}px)`,
|
|
53
|
-
left: `${Number(rect.left) || 0}px`,
|
|
54
|
-
right: `${Number(rect.right) || 0}px`
|
|
55
|
-
}
|
|
56
|
-
};
|
|
40
|
+
// Banners sit just below a top app bar, in a top layout item of their own height, so the page's content starts below
|
|
41
|
+
// them as it starts below the app bar. A surface without one (sign-in pages) has no app bar to sit under, so the
|
|
42
|
+
// banners join the page flow above the content instead. Neither covers the content. `top` is where the banners start:
|
|
43
|
+
// the height of the top app bar, 0 without one.
|
|
44
|
+
function resolveBannerPlacement(top = 0) {
|
|
45
|
+
return Object.freeze({ inline: !(Number(top) > 0) });
|
|
57
46
|
}
|
|
58
47
|
|
|
59
48
|
export {
|
|
@@ -533,7 +533,11 @@ async function reportBannerAndMeasure(page) {
|
|
|
533
533
|
const banner = page.locator(".shell-error-host__banner").first();
|
|
534
534
|
await expect(banner).toBeVisible();
|
|
535
535
|
await page.evaluate(() => new Promise((resolve) => requestAnimationFrame(() => requestAnimationFrame(resolve))));
|
|
536
|
-
return
|
|
536
|
+
return measureBanner(page);
|
|
537
|
+
}
|
|
538
|
+
|
|
539
|
+
function measureBanner(page) {
|
|
540
|
+
return page.locator(".shell-error-host__banner").first().evaluate((element) => {
|
|
537
541
|
const box = (node) => {
|
|
538
542
|
const rect = node.getBoundingClientRect();
|
|
539
543
|
return { top: rect.top, bottom: rect.bottom, left: rect.left, right: rect.right };
|
|
@@ -551,7 +555,9 @@ async function reportBannerAndMeasure(page) {
|
|
|
551
555
|
closeColor,
|
|
552
556
|
closeColorWithThemedDefault,
|
|
553
557
|
appBar: appBar ? box(appBar) : null,
|
|
554
|
-
content:
|
|
558
|
+
// The page's content: inside main, or on a surface without a layout (sign-in) everything outside the host.
|
|
559
|
+
content: Array.from((document.querySelector("main") || document.body).querySelectorAll("h1, p, input, button"))
|
|
560
|
+
.filter((node) => !node.closest(".shell-error-host"))
|
|
555
561
|
.map((node) => ({ name: node.textContent.trim() || node.name, rect: box(node) }))
|
|
556
562
|
};
|
|
557
563
|
});
|
|
@@ -584,11 +590,26 @@ test("shell-web error banners never cover content and keep a readable close butt
|
|
|
584
590
|
|
|
585
591
|
await page.goto(`/home?theme=${theme}`);
|
|
586
592
|
await expect(page.getByTestId("jskit-shell-app-bar")).toBeVisible();
|
|
593
|
+
const answer = page.getByRole("textbox", { name: "Unsaved answer" });
|
|
594
|
+
const contentTop = await answer.evaluate((element) => element.getBoundingClientRect().top);
|
|
587
595
|
const shell = await reportBannerAndMeasure(page);
|
|
588
596
|
assert.ok(
|
|
589
597
|
shell.banner.top >= shell.appBar.bottom - 1,
|
|
590
598
|
`${viewport.width}px ${theme}: the banner overlaps the top app bar.`
|
|
591
599
|
);
|
|
600
|
+
// Under an app bar the banner takes its own room: the content starts below it, so it covers none of it and the
|
|
601
|
+
// content's controls take their own clicks. The layout eases the content down, so the check waits for it.
|
|
602
|
+
await expect.poll(async () => {
|
|
603
|
+
const { banner, content } = await measureBanner(page);
|
|
604
|
+
return content.filter((item) => overlaps(banner, item.rect)).map((item) => item.name);
|
|
605
|
+
}, { message: `${viewport.width}px ${theme}: the banner covers content below the app bar.` }).toEqual([]);
|
|
606
|
+
await answer.click({ trial: true, timeout: 2_000 });
|
|
607
|
+
// Closed, it gives its room back and the content starts where it did.
|
|
608
|
+
await page.locator(".shell-error-host__banner .v-alert__close .v-btn").first().click();
|
|
609
|
+
await expect(page.locator(".shell-error-host__banner")).toHaveCount(0);
|
|
610
|
+
await expect.poll(() => answer.evaluate((element) => element.getBoundingClientRect().top), {
|
|
611
|
+
message: `${viewport.width}px ${theme}: the content does not move back up once the banner closes.`
|
|
612
|
+
}).toBeCloseTo(contentTop, 0);
|
|
592
613
|
await page.close();
|
|
593
614
|
}
|
|
594
615
|
}
|
|
@@ -13,7 +13,16 @@ import { useShellErrorPresentationStore } from "../src/client/stores/useShellErr
|
|
|
13
13
|
import { silentLogger } from "@jskit-ai/kernel/shared/support/silentLogger";
|
|
14
14
|
|
|
15
15
|
const componentUrl = new URL("../src/client/components/ShellErrorHost.vue", import.meta.url).href;
|
|
16
|
+
// The host imports VLayoutItem from Vuetify's own entry, whose CSS Node cannot load; like the other Vuetify
|
|
17
|
+
// components here, it is a stub.
|
|
18
|
+
const layoutStubUrl = `data:text/javascript,${encodeURIComponent(
|
|
19
|
+
"export const VLayoutItem = { name: \"VLayoutItem\", setup: (_props, { slots }) => () => slots.default?.() };"
|
|
20
|
+
)}`;
|
|
16
21
|
const hooks = registerHooks({
|
|
22
|
+
resolve(specifier, context, nextResolve) {
|
|
23
|
+
if (specifier !== "vuetify/components/VLayout") return nextResolve(specifier, context);
|
|
24
|
+
return { url: layoutStubUrl, shortCircuit: true };
|
|
25
|
+
},
|
|
17
26
|
load(url, context, nextLoad) {
|
|
18
27
|
if (url !== componentUrl) return nextLoad(url, context);
|
|
19
28
|
const { descriptor } = parse(readFileSync(new URL(url), "utf8"));
|
|
@@ -52,7 +61,10 @@ function fixture(t) {
|
|
|
52
61
|
app.use(pinia);
|
|
53
62
|
useShellErrorPresentationStore(pinia).attachRuntimeStore(store);
|
|
54
63
|
app.provide(SHELL_WEB_ERROR_RUNTIME_KEY, runtime);
|
|
55
|
-
app.provide(Symbol.for("vuetify:layout"), {
|
|
64
|
+
app.provide(Symbol.for("vuetify:layout"), {
|
|
65
|
+
mainRect: shallowRef({ top: 0, left: 0, right: 0, bottom: 0 }),
|
|
66
|
+
getLayoutItem: () => undefined
|
|
67
|
+
});
|
|
56
68
|
app.provide(Symbol.for("vuetify:display"), { width: shallowRef(1280), mobile: shallowRef(false) });
|
|
57
69
|
globalThis.document = { documentElement: { style: { removeProperty() {} } }, querySelector: () => null };
|
|
58
70
|
for (const name of ["VSnackbar", "VDialog", "VCard", "VCardTitle", "VCardText", "VCardActions", "VSpacer", "VAlert", "VBtn"]) {
|
|
@@ -37,14 +37,8 @@ test("an entry's actions list its action first and skip an empty one", () => {
|
|
|
37
37
|
});
|
|
38
38
|
|
|
39
39
|
test("banners float below a top app bar and join the page without one", () => {
|
|
40
|
-
assert.deepEqual(resolveBannerPlacement(
|
|
41
|
-
assert.deepEqual(resolveBannerPlacement(
|
|
42
|
-
assert.deepEqual(resolveBannerPlacement(
|
|
43
|
-
|
|
44
|
-
style: {
|
|
45
|
-
top: "calc(env(safe-area-inset-top, 0px) + 64px)",
|
|
46
|
-
left: "256px",
|
|
47
|
-
right: "0px"
|
|
48
|
-
}
|
|
49
|
-
});
|
|
40
|
+
assert.deepEqual(resolveBannerPlacement(0), { inline: true });
|
|
41
|
+
assert.deepEqual(resolveBannerPlacement(), { inline: true });
|
|
42
|
+
assert.deepEqual(resolveBannerPlacement(Number.NaN), { inline: true });
|
|
43
|
+
assert.deepEqual(resolveBannerPlacement(64), { inline: false });
|
|
50
44
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import assert from "node:assert/strict";
|
|
2
2
|
import test from "node:test";
|
|
3
|
-
import { markRaw, nextTick, ref, shallowRef } from "vue";
|
|
3
|
+
import { markRaw, nextTick, reactive, ref, shallowRef } from "vue";
|
|
4
4
|
import { createPinia } from "pinia";
|
|
5
5
|
import { useShellErrorHost } from "../src/client/composables/useShellErrorHost.js";
|
|
6
6
|
import { SHELL_WEB_ERROR_RUNTIME_KEY } from "../src/client/error/inject.js";
|
|
@@ -46,16 +46,18 @@ function mountHost(t, { top = 0, width = 1280 } = {}) {
|
|
|
46
46
|
useShellErrorPresentationStore(pinia).attachRuntimeStore(store);
|
|
47
47
|
const reports = [];
|
|
48
48
|
const layoutRect = shallowRef({ top, left: 0, right: 0, bottom: 0 });
|
|
49
|
+
// The layout items Vuetify has placed, by name, each with the rect it starts at.
|
|
50
|
+
const layoutItems = reactive(new Map());
|
|
49
51
|
const windowWidth = ref(width);
|
|
50
52
|
const { app, result } = mountComposable(useShellErrorHost, {
|
|
51
53
|
plugins: [pinia],
|
|
52
54
|
provide: [
|
|
53
55
|
[SHELL_WEB_ERROR_RUNTIME_KEY, { report: (event) => reports.push(event) }],
|
|
54
|
-
[Symbol.for("vuetify:layout"), { mainRect: layoutRect }],
|
|
56
|
+
[Symbol.for("vuetify:layout"), { mainRect: layoutRect, getLayoutItem: (name) => layoutItems.get(name) }],
|
|
55
57
|
[Symbol.for("vuetify:display"), { width: windowWidth, mobile: ref(false) }]
|
|
56
58
|
]
|
|
57
59
|
});
|
|
58
|
-
return { app, heights, host: result, layoutRect, observers, openSurfaces, reports, store, windowWidth };
|
|
60
|
+
return { app, heights, host: result, layoutItems, layoutRect, observers, openSurfaces, reports, store, windowWidth };
|
|
59
61
|
}
|
|
60
62
|
|
|
61
63
|
test("snackbars show one at a time and the next opens after the last one leaves", async (t) => {
|
|
@@ -181,3 +183,45 @@ test("inline banners publish their height and withdraw it when they float or go"
|
|
|
181
183
|
app.unmount();
|
|
182
184
|
assert.equal(heights.size, 0);
|
|
183
185
|
});
|
|
186
|
+
|
|
187
|
+
test("below an app bar the banners take a top layout item of their own height, so the content starts below them", async (t) => {
|
|
188
|
+
const { app, heights, host, layoutItems, layoutRect } = mountHost(t, { top: 64 });
|
|
189
|
+
const element = markRaw({ getBoundingClientRect: () => ({ height: 40.2 }) });
|
|
190
|
+
assert.equal(host.bannerPlacement.value.inline, false);
|
|
191
|
+
|
|
192
|
+
host.bannersElement.value = element;
|
|
193
|
+
await nextTick();
|
|
194
|
+
assert.deepEqual(host.bannerLayoutItemProps.value, {
|
|
195
|
+
name: "shell-error-host-banners",
|
|
196
|
+
order: 1,
|
|
197
|
+
position: "top",
|
|
198
|
+
size: 41,
|
|
199
|
+
modelValue: true,
|
|
200
|
+
style: { zIndex: 2600 }
|
|
201
|
+
});
|
|
202
|
+
assert.equal(heights.size, 0, "Only inline banners publish their height.");
|
|
203
|
+
|
|
204
|
+
// Vuetify places the item under the app bar and starts the content below both: the banners still float.
|
|
205
|
+
layoutItems.set("shell-error-host-banners", { top: 64, left: 0, right: 0, bottom: 0, size: 41, position: "top" });
|
|
206
|
+
layoutRect.value = { top: 105, left: 0, right: 0, bottom: 0 };
|
|
207
|
+
await nextTick();
|
|
208
|
+
assert.equal(host.bannerPlacement.value.inline, false);
|
|
209
|
+
assert.equal(host.bannerLayoutItemProps.value.size, 41);
|
|
210
|
+
|
|
211
|
+
// Without the app bar they start at the top: they join the page flow and give the layout their room back.
|
|
212
|
+
layoutItems.set("shell-error-host-banners", { top: 0, left: 0, right: 0, bottom: 0, size: 41, position: "top" });
|
|
213
|
+
await nextTick();
|
|
214
|
+
assert.equal(host.bannerPlacement.value.inline, true);
|
|
215
|
+
assert.equal(host.bannerLayoutItemProps.value.size, 0);
|
|
216
|
+
assert.equal(heights.get("--shell-error-banners-inline-height"), "41px");
|
|
217
|
+
|
|
218
|
+
layoutItems.delete("shell-error-host-banners");
|
|
219
|
+
layoutRect.value = { top: 64, left: 0, right: 0, bottom: 0 };
|
|
220
|
+
await nextTick();
|
|
221
|
+
assert.equal(host.bannerLayoutItemProps.value.size, 41);
|
|
222
|
+
host.bannersElement.value = null;
|
|
223
|
+
await nextTick();
|
|
224
|
+
assert.equal(host.bannerLayoutItemProps.value.size, 0, "Banners that go give their room back.");
|
|
225
|
+
assert.equal(heights.size, 0);
|
|
226
|
+
app.unmount();
|
|
227
|
+
});
|