fix(ui/events): mount every step so switching shows no loading state

KeepAlive removed the skeleton on a revisit but not on a first visit, so
tabbing through the steps still flashed. Every panel now mounts when the
page opens and only the active one is on screen, so a switch shows what
was already read. The wrapper is a single element because a panel whose
template is a fragment cannot be hidden with v-show.

usePoll goes back to reading only document.hidden, since nothing is kept
alive and deactivated any more.
This commit is contained in:
sam committed 2026-11-26 03:47:57 +11:00
1 parent a7686042e5
commit f27317738d
2 files changed
+19 -16

No files matched your search

+16 -9
View File
@@ -89,9 +89,13 @@ onMounted(() => void loadCounts());
const steps = computed(() => stepsFor(tabs.value));
/** The panel the active step shows. Undefined when this composition backs none
* of them, which the template renders as an empty state. */
const panel = computed(() => PANELS[active.value]);
/** The panels to draw: one per step this composition backs. */
const panels = computed(() =>
tabs.value.flatMap((tab) => {
const component = PANELS[tab.id];
return component ? [{ id: tab.id, component }] : [];
}),
);
</script>
<template>
@@ -117,12 +121,15 @@ const panel = computed(() => PANELS[active.value]);
</TabsList>
</Tabs>
<!-- Kept alive so returning to a step shows what it already read rather
than its skeleton again. Each panel reads on mount and only on a live
event after that. -->
<KeepAlive v-if="panel">
<component :is="panel" :key="active" />
</KeepAlive>
<!-- Every step stays mounted so a switch shows what it already read rather
than its skeleton. Each panel reads on mount and again on a live event,
and only the active one is on screen. The wrapper is a single element
because v-show cannot hide a component whose template is a fragment. -->
<template v-if="panels.length">
<div v-for="item in panels" :key="item.id" v-show="item.id === active">
<component :is="item.component" />
</div>
</template>
<Empty v-else>
<EmptyHeader>
<EmptyTitle>Event automation is not enabled</EmptyTitle>
+3 -7
View File
@@ -1,4 +1,4 @@
import { onActivated, onDeactivated, onScopeDispose, ref, shallowRef, type Ref, type ShallowRef } from "vue";
import { onScopeDispose, ref, shallowRef, type Ref, type ShallowRef } from "vue";
import { errors } from "@/copy/errors";
import { describeError } from "./api";
@@ -37,14 +37,10 @@ export function useRead<T>(read: () => Promise<T>): Read<T> {
}
/** usePoll re-reads every intervalMs while the tab is visible, for views
* whose data the live stream does not carry. A view kept alive by KeepAlive
* pauses while it is hidden, so every visited tab is not polling at once. */
* whose data the live stream does not carry. */
export function usePoll(reload: () => unknown, intervalMs = 5000): void {
let shown = true;
onActivated(() => (shown = true));
onDeactivated(() => (shown = false));
const timer = setInterval(() => {
if (shown && !document.hidden) void reload();
if (!document.hidden) void reload();
}, intervalMs);
onScopeDispose(() => clearInterval(timer));
}