fix(webui): bind the capture pane to the list it sits beside
The pane was capped against the viewport, which let it grow taller than the box it lives in on a short list -- and a sticky element taller than its container is a sticky element that cannot stick. It is now capped by the list's own measured height and by the room the window has, whichever is smaller: both are sizes the pane does not influence, so filling the cap cannot feed back into it. Stacked, where there is no sibling to be bound by, the panel caps itself at 62vh the way the task log does, so one large payload is a scrolling payload rather than a ten-thousand-pixel page.
This commit is contained in:
5 files changed
+96
-25
No files matched your search
@@ -1,4 +1,5 @@
|
||||
<script setup lang="ts">
|
||||
import { useMediaQuery } from "@vueuse/core";
|
||||
import { computed, ref, watch } from "vue";
|
||||
|
||||
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card";
|
||||
@@ -11,15 +12,30 @@ import { selected } from "./state";
|
||||
*
|
||||
* A pane rather than a sheet: a sheet covers the list it was opened from and
|
||||
* has to be dismissed between rows, while an inspector is read by moving down
|
||||
* the list with the payload in view. On the wide layout it sticks beside the
|
||||
* list and scrolls internally, so a long payload cannot take the page with it;
|
||||
* stacked under the list, a selection brings it into view, because a tap that
|
||||
* changes something off-screen reads as a tap that did nothing.
|
||||
* the list with the payload in view.
|
||||
*
|
||||
* `maxHeight` is the cap the page worked out -- the list's height, or the room
|
||||
* the window has, whichever is smaller -- so a payload of any size stays a
|
||||
* payload beside the list instead of becoming a page of its own. Its title sits
|
||||
* outside the scrolling area: what an operator scrolls back to is the top of
|
||||
* the record, not the top of the panel.
|
||||
*
|
||||
* Stacked under the list there is no cap to fill, so a selection brings the
|
||||
* pane into view instead -- a tap that changes something off-screen reads as a
|
||||
* tap that did nothing.
|
||||
*
|
||||
* Nothing here goes stale: a stored capture is never rewritten.
|
||||
*/
|
||||
const props = defineProps<{ maxHeight?: number | null }>();
|
||||
|
||||
const pane = ref<HTMLElement | null>(null);
|
||||
|
||||
// The pane is in its stacked layout exactly when the grid is: same breakpoint
|
||||
// as CapturesPage, matched there in CSS and here in script.
|
||||
const stacked = useMediaQuery("(max-width: 1099px)");
|
||||
|
||||
const cap = computed(() => (stacked.value || !props.maxHeight ? undefined : `${props.maxHeight}px`));
|
||||
|
||||
const meta = computed(() => {
|
||||
const capture = selected.value;
|
||||
if (!capture) return "";
|
||||
@@ -28,27 +44,28 @@ const meta = computed(() => {
|
||||
.join(" · ");
|
||||
});
|
||||
|
||||
// Below the split's breakpoint the pane sits after the list, so a row click has
|
||||
// to bring it into view. Same breakpoint as the grid in CapturesPage: one
|
||||
// layout decision, expressed twice because CSS cannot hand it to script.
|
||||
const STACKED = "(max-width: 1099px)";
|
||||
|
||||
watch(selected, () => {
|
||||
if (!window.matchMedia(STACKED).matches) return;
|
||||
if (!stacked.value) return;
|
||||
pane.value?.scrollIntoView({ block: "start", behavior: "smooth" });
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div v-if="selected" ref="pane" class="min-w-0 min-[1100px]:sticky min-[1100px]:top-4">
|
||||
<Card class="min-[1100px]:max-h-[calc(100vh-3rem)] min-[1100px]:overflow-y-auto">
|
||||
<div v-if="selected" ref="pane" class="min-w-0">
|
||||
<Card class="flex flex-col" :style="cap ? { maxHeight: cap } : undefined">
|
||||
<CardHeader>
|
||||
<CardTitle class="font-mono">{{ selected.source || "Unknown source" }}</CardTitle>
|
||||
<CardDescription>{{ meta }}</CardDescription>
|
||||
</CardHeader>
|
||||
<CardContent class="flex flex-col gap-5">
|
||||
<CapturePayload label="Payload" :raw="selected.body" />
|
||||
<CapturePayload label="Headers" :raw="selected.headers" />
|
||||
<!-- Stacked there is no sibling to be bound by, so the panel caps itself
|
||||
the way the task log does rather than letting one large payload
|
||||
become a ten-thousand-pixel page. Split, the page's cap is the bound
|
||||
and this one is lifted. -->
|
||||
<CardContent class="min-h-0 max-h-[62vh] overflow-y-auto min-[1100px]:max-h-none">
|
||||
<div class="flex flex-col gap-5">
|
||||
<CapturePayload label="Payload" :raw="selected.body" />
|
||||
<CapturePayload label="Headers" :raw="selected.headers" />
|
||||
</div>
|
||||
</CardContent>
|
||||
</Card>
|
||||
</div>
|
||||
|
||||
@@ -4,7 +4,11 @@ import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/com
|
||||
import CapturesList from "./CapturesList.vue";
|
||||
|
||||
/** The captured events panel, with the note that qualifies everything inside
|
||||
* it: what an operator reads here has already been through redaction. */
|
||||
* it: what an operator reads here has already been through redaction.
|
||||
*
|
||||
* The card grows with its rows, and the pane beside it is capped by this
|
||||
* card's height -- so the list is what an operator scrolls, never a nested box
|
||||
* inside a box. */
|
||||
</script>
|
||||
|
||||
<template>
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
<script setup lang="ts">
|
||||
import { onMounted, watch } from "vue";
|
||||
import { useMediaQuery } from "@vueuse/core";
|
||||
import { onBeforeUnmount, onMounted, ref, watch } from "vue";
|
||||
import { useRoute, useRouter } from "vue-router";
|
||||
|
||||
import CaptureDetail from "./CaptureDetail.vue";
|
||||
@@ -17,13 +18,54 @@ import { load, selectById, selectNewest, selected, useCaptures } from "./state";
|
||||
* reading survives a reload and can be linked to. Selecting is a `replace`, not
|
||||
* a push, so walking the list adds no history entries to back out through.
|
||||
* Narrow screens stack the pane under the list.
|
||||
*
|
||||
* The pane is capped by the list it sits beside and by the room the window has
|
||||
* for it -- never by its own content, which a payload has plenty of. Both of
|
||||
* those are sizes the pane does not influence, so filling the cap cannot feed
|
||||
* back into it; the page therefore stays as tall as the list, however large the
|
||||
* payload.
|
||||
*/
|
||||
useCaptures();
|
||||
|
||||
const route = useRoute();
|
||||
const router = useRouter();
|
||||
|
||||
const listColumn = ref<HTMLElement | null>(null);
|
||||
const paneCap = ref<number | null>(null);
|
||||
|
||||
// The same breakpoint the grid states in its classes: one layout decision,
|
||||
// expressed twice because CSS cannot hand it to script.
|
||||
const stacked = useMediaQuery("(max-width: 1099px)");
|
||||
|
||||
// Below the frame: the room left under the pane's own top edge. A margin
|
||||
// rather than a measured padding on purpose -- being a few pixels out costs a
|
||||
// few pixels, where measuring it from a frame that grows with its content
|
||||
// costs a runaway height.
|
||||
const FLOOR_MARGIN = 24;
|
||||
const MIN_PANE = 320;
|
||||
|
||||
function measure(): void {
|
||||
const column = listColumn.value;
|
||||
if (stacked.value || !column) {
|
||||
paneCap.value = null;
|
||||
return;
|
||||
}
|
||||
const rect = column.getBoundingClientRect();
|
||||
const listHeight = rect.height;
|
||||
const room = window.innerHeight - rect.top - FLOOR_MARGIN;
|
||||
paneCap.value = Math.max(MIN_PANE, Math.min(listHeight || MIN_PANE, room));
|
||||
}
|
||||
|
||||
let observer: ResizeObserver | null = null;
|
||||
|
||||
onMounted(async () => {
|
||||
measure();
|
||||
if (listColumn.value) {
|
||||
observer = new ResizeObserver(measure);
|
||||
observer.observe(listColumn.value);
|
||||
}
|
||||
window.addEventListener("resize", measure);
|
||||
|
||||
await load();
|
||||
// The URL names a selection before the window is read, so the restore waits
|
||||
// for the list; an id it no longer holds falls back to the newest capture,
|
||||
@@ -32,6 +74,12 @@ onMounted(async () => {
|
||||
if (!Number.isInteger(named) || !selectById(named)) selectNewest();
|
||||
});
|
||||
|
||||
onBeforeUnmount(() => {
|
||||
observer?.disconnect();
|
||||
window.removeEventListener("resize", measure);
|
||||
});
|
||||
watch(stacked, measure);
|
||||
|
||||
watch(selected, (capture) => {
|
||||
const query = { ...route.query };
|
||||
if (capture) query.capture = String(capture.id);
|
||||
@@ -43,7 +91,9 @@ watch(selected, (capture) => {
|
||||
<template>
|
||||
<CapturesHeader />
|
||||
<div class="grid min-w-0 items-start gap-4 min-[1100px]:grid-cols-[minmax(0,1fr)_minmax(0,1fr)]">
|
||||
<CapturesCard class="min-w-0" />
|
||||
<CaptureDetail />
|
||||
<div ref="listColumn" class="min-w-0">
|
||||
<CapturesCard />
|
||||
</div>
|
||||
<CaptureDetail :max-height="paneCap" />
|
||||
</div>
|
||||
</template>
|
||||
Reference in new issue
Block a user