@cosmicdrift/kumiko-renderer-web 0.245.0 → 0.247.0

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cosmicdrift/kumiko-renderer-web",
3
- "version": "0.245.0",
3
+ "version": "0.247.0",
4
4
  "description": "Web-platform bindings for @cosmicdrift/kumiko-renderer. HTML default-primitives, browser history-based navigation, EventSource-backed live events, and a one-call createKumikoApp that mounts the whole stack via react-dom.",
5
5
  "license": "BUSL-1.1",
6
6
  "author": "Marc Frost <marc@cosmicdriftgamestudio.com>",
@@ -16,9 +16,9 @@
16
16
  "./styles.css": "./src/styles.css"
17
17
  },
18
18
  "dependencies": {
19
- "@cosmicdrift/kumiko-dispatcher-live": "0.245.0",
20
- "@cosmicdrift/kumiko-headless": "0.245.0",
21
- "@cosmicdrift/kumiko-renderer": "0.245.0",
19
+ "@cosmicdrift/kumiko-dispatcher-live": "0.247.0",
20
+ "@cosmicdrift/kumiko-headless": "0.247.0",
21
+ "@cosmicdrift/kumiko-renderer": "0.247.0",
22
22
  "@radix-ui/react-dialog": "^1.1.15",
23
23
  "@radix-ui/react-dropdown-menu": "^2.1.16",
24
24
  "@radix-ui/react-label": "^2.1.8",
@@ -64,7 +64,7 @@
64
64
  "@types/react-dom": "^19.2.3",
65
65
  "jsdom": "^29.1.1",
66
66
  "tailwindcss": "^4.3.0",
67
- "@cosmicdrift/kumiko-locale-de": "0.245.0"
67
+ "@cosmicdrift/kumiko-locale-de": "0.247.0"
68
68
  },
69
69
  "repository": {
70
70
  "type": "git",
@@ -21,8 +21,8 @@ import type {
21
21
  TreeChildrenSubscribe,
22
22
  TreeNode,
23
23
  } from "@cosmicdrift/kumiko-framework/engine";
24
- import type { FeatureSchema, LiveEventSubscriber } from "@cosmicdrift/kumiko-renderer";
25
- import { LiveEventsProvider } from "@cosmicdrift/kumiko-renderer";
24
+ import type { FeatureSchema, LiveEventSubscriber, NavApi } from "@cosmicdrift/kumiko-renderer";
25
+ import { LiveEventsProvider, NavProvider } from "@cosmicdrift/kumiko-renderer";
26
26
  import { act } from "@testing-library/react";
27
27
  import type { ReactNode } from "react";
28
28
  import { NavProvidersProvider } from "../app/nav-providers-context";
@@ -463,6 +463,90 @@ describe("NavTree navBadges (Runtime-Badge-Slot)", () => {
463
463
  });
464
464
  });
465
465
 
466
+ // fw#2724: leaving a list for a sub-screen (entityEdit/actionForm/...) used
467
+ // to lose BOTH orientation cues at once — nav marks nothing, breadcrumb
468
+ // shrinks to one crumb. NavTree now falls back to resolveParentScreenId
469
+ // (same resolution shell-breadcrumb.ts uses) when the routed screen has no
470
+ // node of its own in the tree.
471
+ function navWithRoute(screenId: string): NavApi {
472
+ return {
473
+ route: { screenId },
474
+ navigate: () => {},
475
+ replace: () => {},
476
+ hrefFor: () => "",
477
+ searchParams: {},
478
+ setSearchParams: () => {},
479
+ };
480
+ }
481
+
482
+ describe("NavTree active-marker parent fallback", () => {
483
+ test("screen without its own nav entry highlights the resolved parent, without aria-current", () => {
484
+ const schema: FeatureSchema = {
485
+ featureName: "showcase",
486
+ entities: {},
487
+ screens: [
488
+ { id: "user-list", type: "entityList", entity: "profile", columns: [] },
489
+ {
490
+ id: "user-edit",
491
+ type: "entityEdit",
492
+ // Deliberately a DIFFERENT entity than "user-list" — the old
493
+ // same-entity heuristic must NOT be what resolves this; only the
494
+ // explicit listScreenId does.
495
+ entity: "user-detail",
496
+ listScreenId: "user-list",
497
+ layout: { sections: [{ fields: [] }] },
498
+ },
499
+ ],
500
+ navs: [{ id: "user-list", label: "Users", screen: "user-list", order: 10 }],
501
+ } as FeatureSchema;
502
+
503
+ render(
504
+ <NavProvider value={navWithRoute("user-edit")}>
505
+ <NavTree schema={schema} />
506
+ </NavProvider>,
507
+ );
508
+
509
+ const link = screen.getByText("Users").closest("a");
510
+ expect(link?.getAttribute("data-active")).toBe("true");
511
+ expect(link?.hasAttribute("aria-current")).toBe(false);
512
+ });
513
+
514
+ test("screen with its own nav entry still marks itself and keeps aria-current=page", () => {
515
+ const schema: FeatureSchema = {
516
+ featureName: "showcase",
517
+ entities: {},
518
+ screens: [
519
+ { id: "user-list", type: "entityList", entity: "profile", columns: [] },
520
+ {
521
+ id: "user-edit",
522
+ type: "entityEdit",
523
+ entity: "profile",
524
+ layout: { sections: [{ fields: [] }] },
525
+ },
526
+ ],
527
+ navs: [
528
+ { id: "user-list", label: "Users", screen: "user-list", order: 10 },
529
+ { id: "user-edit", label: "Edit User", screen: "user-edit", order: 20 },
530
+ ],
531
+ } as FeatureSchema;
532
+
533
+ render(
534
+ <NavProvider value={navWithRoute("user-edit")}>
535
+ <NavTree schema={schema} />
536
+ </NavProvider>,
537
+ );
538
+
539
+ const editLink = screen.getByText("Edit User").closest("a");
540
+ expect(editLink?.getAttribute("data-active")).toBe("true");
541
+ expect(editLink?.getAttribute("aria-current")).toBe("page");
542
+
543
+ // The list is not silently highlighted too — only the exact match is.
544
+ const listLink = screen.getByText("Users").closest("a");
545
+ expect(listLink?.getAttribute("data-active")).toBe("false");
546
+ expect(listLink?.hasAttribute("aria-current")).toBe(false);
547
+ });
548
+ });
549
+
466
550
  // ── Visual-Tree-Merge: dynamische Knoten in der EINEN Nav ──────────────
467
551
  //
468
552
  // Beweist die vier Caps die NavTree aus dem alten VisualTree übernimmt:
@@ -437,6 +437,71 @@ describe("DataTable", () => {
437
437
  expect(onRowClick).toHaveBeenCalledWith(row);
438
438
  });
439
439
 
440
+ // chromeless (fw#2722): a relatedList section in a tabs-mode Akte already
441
+ // sits inside a tab panel — the table's own card frame would nest a card
442
+ // inside that boundary without separating anything further.
443
+ describe("chromeless", () => {
444
+ const cols = [{ field: "name", label: "Name", type: "string", sortable: false }] as const;
445
+ const oneRow = [{ id: "r1", values: { name: "Alice" } }];
446
+
447
+ // Table itself renders its own [data-slot="table-container"] wrapper div
448
+ // (ui/table.tsx) around the <table data-testid> — the card frame lives
449
+ // one level up, on DefaultDataTable's own wrapping div.
450
+ test("default: table renders with its own card frame", () => {
451
+ render(<DataTable columns={cols} rows={oneRow} testId="t" />);
452
+ const wrapper = screen.getByTestId("t").parentElement?.parentElement;
453
+ expect(wrapper?.className).toContain("border");
454
+ expect(wrapper?.className).toContain("rounded-lg");
455
+ expect(wrapper?.className).toContain("bg-card");
456
+ });
457
+
458
+ test("chromeless: table drops the card frame, table markup is unchanged", () => {
459
+ render(<DataTable columns={cols} rows={oneRow} testId="t" chromeless />);
460
+ const wrapper = screen.getByTestId("t").parentElement?.parentElement;
461
+ expect(wrapper?.className).not.toContain("border");
462
+ expect(wrapper?.className).not.toContain("rounded-lg");
463
+ expect(wrapper?.className).not.toContain("bg-card");
464
+ expect(screen.getByTestId("row-r1")).not.toBeNull();
465
+ });
466
+ });
467
+
468
+ // scrollBody (fw#2722): a relatedList section in a tabs-mode Akte must not
469
+ // stretch the whole page with a long list, or leave dead space below a
470
+ // short one — bounds the table to a fixed height and scrolls rows inside
471
+ // it, regardless of how many rows there are.
472
+ describe("scrollBody", () => {
473
+ const cols = [{ field: "name", label: "Name", type: "string", sortable: false }] as const;
474
+ const shortRows = [{ id: "r1", values: { name: "Alice" } }];
475
+ const longRows = Array.from({ length: 50 }, (_, i) => ({
476
+ id: `r${i}`,
477
+ values: { name: `Row ${i}` },
478
+ }));
479
+
480
+ test("default: table has no fixed height and grows with its content", () => {
481
+ render(<DataTable columns={cols} rows={longRows} testId="t" />);
482
+ const wrapper = screen.getByTestId("t").parentElement?.parentElement;
483
+ expect(wrapper?.className).not.toContain("overflow-y-auto");
484
+ expect(wrapper?.className).toContain("overflow-hidden");
485
+ });
486
+
487
+ test("scrollBody: a long list fills its flex container and scrolls internally", () => {
488
+ render(<DataTable columns={cols} rows={longRows} testId="t" scrollBody />);
489
+ const wrapper = screen.getByTestId("t").parentElement?.parentElement;
490
+ expect(wrapper?.className).toContain("overflow-y-auto");
491
+ expect(wrapper?.className).toContain("flex-1");
492
+ expect(wrapper?.className).toContain("min-h-0");
493
+ expect(screen.getAllByTestId(/^row-/)).toHaveLength(50);
494
+ });
495
+
496
+ test("scrollBody: a short list gets the same flex-fill treatment (fills space instead of shrinking)", () => {
497
+ render(<DataTable columns={cols} rows={shortRows} testId="t" scrollBody />);
498
+ const wrapper = screen.getByTestId("t").parentElement?.parentElement;
499
+ expect(wrapper?.className).toContain("overflow-y-auto");
500
+ expect(wrapper?.className).toContain("flex-1");
501
+ expect(wrapper?.className).toContain("min-h-0");
502
+ });
503
+ });
504
+
440
505
  // Sort-Header pinnt das 3-State-Toggle-Verhalten + Visual-Indicator
441
506
  // + aria-sort. Renderer-Vertrag mit dem Caller (RenderList): jede
442
507
  // sortable-Column liefert beim Click den nächsten Sort-State zurück
@@ -1450,6 +1515,37 @@ describe("Form", () => {
1450
1515
  const contentContainer = footer.previousElementSibling as HTMLElement;
1451
1516
  expect(contentContainer.className).not.toContain("max-sm:pb-32");
1452
1517
  });
1518
+
1519
+ // fillHeight (fw#2722): the flex-fill chain RenderEdit opts a lone
1520
+ // relatedList tab into, so its table can scroll inside the tab panel
1521
+ // instead of the whole page stretching to the row count.
1522
+ test("fillHeight: form root and its content container size to h-full/flex-1 min-h-0", () => {
1523
+ render(
1524
+ <Form onSubmit={() => undefined} testId="form" fillHeight>
1525
+ <div>content</div>
1526
+ </Form>,
1527
+ );
1528
+ const form = screen.getByTestId("form");
1529
+ expect(form.className).toContain("h-full");
1530
+ expect(form.className).toContain("min-h-0");
1531
+ // form > FormScreenShell > card(overflow-hidden) — the card is the
1532
+ // flex-1 min-h-0 child that claims the remaining height below headerRegion.
1533
+ const card = form.firstElementChild?.firstElementChild as HTMLElement;
1534
+ expect(card.className).toContain("flex-1");
1535
+ expect(card.className).toContain("min-h-0");
1536
+ });
1537
+
1538
+ test("without fillHeight: form root keeps its normal, content-sized height", () => {
1539
+ render(
1540
+ <Form onSubmit={() => undefined} testId="form">
1541
+ <div>content</div>
1542
+ </Form>,
1543
+ );
1544
+ const form = screen.getByTestId("form");
1545
+ expect(form.className).not.toContain("h-full");
1546
+ const card = form.firstElementChild?.firstElementChild as HTMLElement;
1547
+ expect(card.className).not.toContain("flex-1");
1548
+ });
1453
1549
  });
1454
1550
 
1455
1551
  describe("Banner padded", () => {
@@ -923,3 +923,143 @@ describe("KumikoScreen / projectionDetail extension section with its own <form>
923
923
  expect(outerSubmitFired).toBe(false);
924
924
  });
925
925
  });
926
+
927
+ // fw#2713: `actions` are on the record the head shows, not on whichever tab
928
+ // is open — they used to render in the card footer, below the active tab's
929
+ // content, so a long tab pushed them off-screen and they visually "moved"
930
+ // as the tab content's length changed. They now render inside the head
931
+ // region (title/status/metrics), before any tab content, in both layout
932
+ // modes — `single` gets the same treatment as `tabs` since the actions
933
+ // belong to the header regardless of how the body is laid out.
934
+ describe("KumikoScreen / projectionDetail header actions placement (fw#2713)", () => {
935
+ const dispatcher: Dispatcher = createMockDispatcher({
936
+ query: (async () => ({
937
+ isSuccess: true,
938
+ data: { userId: "user-42", createdAt: "2026-07-01T00:00:00Z" },
939
+ })) as unknown as Dispatcher["query"],
940
+ });
941
+
942
+ test("with actions declared: the action button renders in the head region, before the tab content, not in the form footer", async () => {
943
+ const screenWithActions: ProjectionDetailScreenDefinition = {
944
+ ...detailScreen,
945
+ header: { title: "userId" },
946
+ layout: { mode: "tabs", sections: detailScreen.layout.sections },
947
+ actions: [
948
+ {
949
+ kind: "navigate",
950
+ id: "open-user",
951
+ label: "sessions.detail.action.openUser",
952
+ screen: "user-detail",
953
+ },
954
+ ],
955
+ };
956
+ const schemaWithActions: FeatureSchema = {
957
+ featureName: "sessions",
958
+ entities: {},
959
+ screens: [screenWithActions],
960
+ };
961
+
962
+ render(
963
+ <DispatcherProvider dispatcher={dispatcher}>
964
+ <KumikoScreen
965
+ schema={schemaWithActions}
966
+ qn="sessions:screen:session-detail"
967
+ entityId="sess-1"
968
+ />
969
+ </DispatcherProvider>,
970
+ );
971
+
972
+ const actionButton = await waitFor(() => screen.getByTestId("render-edit-action-open-user"));
973
+ // The footer regions RenderEdit's Form would otherwise draw the action
974
+ // into are gone entirely — the action moved out, it didn't just gain a
975
+ // second home.
976
+ expect(screen.queryByTestId("render-edit-form-actions")).toBeNull();
977
+ expect(screen.queryByTestId("render-edit-form-actions-secondary")).toBeNull();
978
+ // The action sits in the head Card, ahead of the field it shares a
979
+ // screen with in document order — i.e. inside headerRegion, not the
980
+ // card body below it.
981
+ const field = screen.getByTestId("field-userId");
982
+ expect(
983
+ actionButton.compareDocumentPosition(field) & Node.DOCUMENT_POSITION_FOLLOWING,
984
+ ).toBeTruthy();
985
+ });
986
+
987
+ test("without actions: no action area renders at all (no empty strip, no leftover footer)", async () => {
988
+ render(
989
+ <DispatcherProvider dispatcher={dispatcher}>
990
+ <KumikoScreen schema={schema} qn="sessions:screen:session-detail" entityId="sess-1" />
991
+ </DispatcherProvider>,
992
+ );
993
+
994
+ await waitFor(() => screen.getByTestId("render-edit-form"));
995
+ expect(screen.queryByTestId("kumiko-screen-projection-detail-actions")).toBeNull();
996
+ expect(screen.queryByTestId("render-edit-form-actions")).toBeNull();
997
+ expect(screen.queryByTestId("render-edit-form-actions-secondary")).toBeNull();
998
+ });
999
+
1000
+ test("switching tabs leaves the action in place — same head placement regardless of which tab is active", async () => {
1001
+ const tabsScreen: ProjectionDetailScreenDefinition = {
1002
+ ...detailScreen,
1003
+ header: { title: "userId" },
1004
+ layout: {
1005
+ mode: "tabs",
1006
+ sections: [
1007
+ { id: "overview", title: "Session", fields: ["userId"] },
1008
+ { id: "meta", title: "Meta", fields: ["createdAt"] },
1009
+ ],
1010
+ },
1011
+ actions: [
1012
+ {
1013
+ kind: "navigate",
1014
+ id: "open-user",
1015
+ label: "sessions.detail.action.openUser",
1016
+ screen: "user-detail",
1017
+ },
1018
+ ],
1019
+ };
1020
+ const tabsSchema: FeatureSchema = {
1021
+ featureName: "sessions",
1022
+ entities: {},
1023
+ screens: [tabsScreen],
1024
+ };
1025
+ function navWithTab(tab: string | undefined): NavApi {
1026
+ return {
1027
+ route: undefined,
1028
+ navigate: () => {},
1029
+ replace: () => {},
1030
+ hrefFor: () => "",
1031
+ searchParams: tab !== undefined ? { tab } : {},
1032
+ setSearchParams: () => {},
1033
+ };
1034
+ }
1035
+
1036
+ const { unmount } = render(
1037
+ <NavProvider value={navWithTab("overview")}>
1038
+ <DispatcherProvider dispatcher={dispatcher}>
1039
+ <KumikoScreen schema={tabsSchema} qn="sessions:screen:session-detail" entityId="sess-1" />
1040
+ </DispatcherProvider>
1041
+ </NavProvider>,
1042
+ );
1043
+ const buttonOnOverview = await waitFor(() =>
1044
+ screen.getByTestId("render-edit-action-open-user"),
1045
+ );
1046
+ expect(buttonOnOverview.textContent).toBe("sessions.detail.action.openUser");
1047
+ unmount();
1048
+
1049
+ render(
1050
+ <NavProvider value={navWithTab("meta")}>
1051
+ <DispatcherProvider dispatcher={dispatcher}>
1052
+ <KumikoScreen schema={tabsSchema} qn="sessions:screen:session-detail" entityId="sess-1" />
1053
+ </DispatcherProvider>
1054
+ </NavProvider>,
1055
+ );
1056
+ const buttonOnMeta = await waitFor(() => screen.getByTestId("render-edit-action-open-user"));
1057
+ expect(buttonOnMeta.textContent).toBe("sessions.detail.action.openUser");
1058
+ // Same head placement on both tabs — ahead of whichever field the
1059
+ // active tab shows, not trailing it.
1060
+ const fieldOnMeta = screen.getByTestId("field-createdAt");
1061
+ expect(
1062
+ buttonOnMeta.compareDocumentPosition(fieldOnMeta) & Node.DOCUMENT_POSITION_FOLLOWING,
1063
+ ).toBeTruthy();
1064
+ });
1065
+ });
@@ -105,4 +105,78 @@ describe("resolveDetailBreadcrumb", () => {
105
105
  test("unknown screen returns undefined", () => {
106
106
  expect(resolveDetailBreadcrumb([], "missing", t)).toBeUndefined();
107
107
  });
108
+
109
+ // fw#2724: explicit `listScreenId` on entityEdit/actionForm must win over
110
+ // the rowAction/entity heuristics, not just supplement them (the way it
111
+ // already did for custom/projectionDetail above).
112
+ test("explicit listScreenId on entityEdit wins over the rowAction heuristic", () => {
113
+ const screens: ScreenDefinition[] = [
114
+ {
115
+ id: "user-list",
116
+ type: "entityList",
117
+ entity: "user",
118
+ columns: ["email"],
119
+ rowActions: [
120
+ {
121
+ kind: "navigate",
122
+ id: "view",
123
+ label: "kumiko.actions.view",
124
+ screen: "user-edit",
125
+ entityId: "id",
126
+ },
127
+ ],
128
+ },
129
+ {
130
+ id: "user-archive",
131
+ type: "entityList",
132
+ entity: "user",
133
+ columns: ["email"],
134
+ rowActions: [],
135
+ },
136
+ {
137
+ id: "user-edit",
138
+ type: "entityEdit",
139
+ entity: "user",
140
+ listScreenId: "user-archive",
141
+ layout: { sections: [{ fields: ["email"] }] },
142
+ },
143
+ ];
144
+ // Without the explicit field, the rowAction heuristic would resolve
145
+ // "user-list" (see "entityList navigate rowAction..." above) — the
146
+ // declared listScreenId overrides that guess.
147
+ expect(resolveDetailBreadcrumb(screens, "user-edit", t)?.[0]?.screenId).toBe("user-archive");
148
+ });
149
+
150
+ // Regression guard: an actionForm without listScreenId (the common case —
151
+ // the field is new and optional) must keep resolving exactly like before,
152
+ // via the rowAction heuristic. Pins that existing apps see no change.
153
+ test("actionForm without listScreenId still resolves via the rowAction heuristic", () => {
154
+ const screens: ScreenDefinition[] = [
155
+ {
156
+ id: "invoice-list",
157
+ type: "entityList",
158
+ entity: "invoice",
159
+ columns: ["status"],
160
+ rowActions: [
161
+ {
162
+ kind: "navigate",
163
+ id: "approve",
164
+ label: "kumiko.actions.view",
165
+ screen: "invoice-approve",
166
+ entityId: "id",
167
+ },
168
+ ],
169
+ },
170
+ {
171
+ id: "invoice-approve",
172
+ type: "actionForm",
173
+ handler: "billing:write:invoice:approve",
174
+ fields: { notes: { type: "text" } },
175
+ layout: { sections: [{ fields: ["notes"] }] },
176
+ },
177
+ ];
178
+ expect(resolveDetailBreadcrumb(screens, "invoice-approve", t)?.[0]?.screenId).toBe(
179
+ "invoice-list",
180
+ );
181
+ });
108
182
  });
@@ -56,6 +56,7 @@ import {
56
56
  SidebarMenuSubItem,
57
57
  useSidebar,
58
58
  } from "../ui/sidebar";
59
+ import { resolveParentScreenId } from "./shell-breadcrumb";
59
60
  import { useDispatchTarget } from "./target-resolver-stub";
60
61
  import { parseTargetFromSearchParams } from "./target-url";
61
62
 
@@ -92,6 +93,24 @@ const NavBadgesContext = createContext<ReadonlyMap<string, ReactNode>>(EMPTY_BAD
92
93
  type NavFilter = { readonly q: string; readonly matches: (rawLabel: string) => boolean };
93
94
  const NavFilterContext = createContext<NavFilter>({ q: "", matches: () => true });
94
95
 
96
+ // Which nav node should highlight for the current route. `exact` means the
97
+ // active screen has its own node in {tree} (aria-current="page" belongs
98
+ // here); otherwise {screenId} is the resolved parent from
99
+ // resolveParentScreenId — a screen reachable only through a list stays
100
+ // orientable, but a Screen-Reader shouldn't be told it IS that list.
101
+ type ActiveScreenMarker = { readonly screenId: string; readonly exact: boolean } | undefined;
102
+ const ActiveScreenMarkerContext = createContext<ActiveScreenMarker>(undefined);
103
+
104
+ // Walks only the static `children` — provider-emitted nodes (treeNodeToNavNode
105
+ // below) never set `screen`, so they can't hide a match this walk would miss.
106
+ function treeContainsScreen(nodes: readonly NavNode[], screenId: string): boolean {
107
+ return nodes.some(
108
+ (n) =>
109
+ (n.screen !== undefined && lastSegment(n.screen) === screenId) ||
110
+ treeContainsScreen(n.children, screenId),
111
+ );
112
+ }
113
+
95
114
  // Ein Knoten überlebt den Filter, wenn er selbst oder ein Nachfahre matcht.
96
115
  // Provider-Kinder sind zur Filterzeit schon materialisiert (Provider-Knoten
97
116
  // sind default-expanded → eager geladen), darum reicht die statische
@@ -115,6 +134,19 @@ export function NavTree({
115
134
  return resolveNavigation({ source, ...(user !== undefined && { user }) });
116
135
  }, [app, user, allowedNavQns]);
117
136
 
137
+ const nav = useNav();
138
+ const activeScreenId = nav.route?.screenId;
139
+ // Same "no nav entry of its own" gap the breadcrumb closes (fw#2724):
140
+ // when the routed screen has no node in {tree}, fall back to its
141
+ // resolved parent so a detail/edit/form screen still orients the user.
142
+ const activeMarker = useMemo((): ActiveScreenMarker => {
143
+ if (activeScreenId === undefined) return undefined;
144
+ if (treeContainsScreen(tree, activeScreenId)) return { screenId: activeScreenId, exact: true };
145
+ const allScreens = app.features.flatMap((f) => f.screens);
146
+ const parentScreenId = resolveParentScreenId(allScreens, activeScreenId);
147
+ return parentScreenId !== undefined ? { screenId: parentScreenId, exact: false } : undefined;
148
+ }, [tree, app.features, activeScreenId]);
149
+
118
150
  // Collapsed-Set: nur die explizit zugeklappten qualified-names. Default
119
151
  // ist also "alles auf" — neue Features tauchen sofort offen auf, ohne
120
152
  // dass der User erst klicken muss.
@@ -148,34 +180,36 @@ export function NavTree({
148
180
  const navFilter = useMemo<NavFilter>(() => ({ q, matches }), [q, matches]);
149
181
 
150
182
  return (
151
- <NavFilterContext.Provider value={navFilter}>
152
- <NavBadgesContext.Provider value={navBadges ?? EMPTY_BADGES}>
153
- <div data-testid={testId} data-kumiko-layout="nav-tree" className="flex w-full flex-col">
154
- <div className="px-2 pt-2 pb-1 group-data-[collapsible=icon]:hidden">
155
- <SidebarInput
156
- value={filter}
157
- onChange={(e) => setFilter(e.target.value)}
158
- placeholder={t("kumiko.nav.search")}
159
- aria-label={t("kumiko.nav.search")}
160
- />
161
- </div>
162
- {tree.map((node) =>
163
- isPureSection(node) ? (
164
- <NavSection
165
- key={node.qualifiedName}
166
- node={node}
167
- collapsed={collapsed}
168
- onToggle={onToggle}
183
+ <ActiveScreenMarkerContext.Provider value={activeMarker}>
184
+ <NavFilterContext.Provider value={navFilter}>
185
+ <NavBadgesContext.Provider value={navBadges ?? EMPTY_BADGES}>
186
+ <div data-testid={testId} data-kumiko-layout="nav-tree" className="flex w-full flex-col">
187
+ <div className="px-2 pt-2 pb-1 group-data-[collapsible=icon]:hidden">
188
+ <SidebarInput
189
+ value={filter}
190
+ onChange={(e) => setFilter(e.target.value)}
191
+ placeholder={t("kumiko.nav.search")}
192
+ aria-label={t("kumiko.nav.search")}
169
193
  />
170
- ) : (
171
- <SidebarMenu key={node.qualifiedName} className="px-2 py-1">
172
- <NavMenuNode node={node} collapsed={collapsed} onToggle={onToggle} />
173
- </SidebarMenu>
174
- ),
175
- )}
176
- </div>
177
- </NavBadgesContext.Provider>
178
- </NavFilterContext.Provider>
194
+ </div>
195
+ {tree.map((node) =>
196
+ isPureSection(node) ? (
197
+ <NavSection
198
+ key={node.qualifiedName}
199
+ node={node}
200
+ collapsed={collapsed}
201
+ onToggle={onToggle}
202
+ />
203
+ ) : (
204
+ <SidebarMenu key={node.qualifiedName} className="px-2 py-1">
205
+ <NavMenuNode node={node} collapsed={collapsed} onToggle={onToggle} />
206
+ </SidebarMenu>
207
+ ),
208
+ )}
209
+ </div>
210
+ </NavBadgesContext.Provider>
211
+ </NavFilterContext.Provider>
212
+ </ActiveScreenMarkerContext.Provider>
179
213
  );
180
214
  }
181
215
 
@@ -387,6 +421,9 @@ type NavNodeState = {
387
421
  readonly expandable: boolean;
388
422
  readonly isExpanded: boolean;
389
423
  readonly active: boolean;
424
+ // Narrower than `active`: true only for the node that IS the routed
425
+ // screen — never for a parent-fallback match. Drives aria-current="page".
426
+ readonly ariaCurrent: boolean;
390
427
  readonly childNodes: readonly NavNode[];
391
428
  readonly hidden: boolean;
392
429
  readonly providerLoading: boolean;
@@ -416,8 +453,12 @@ function useNavNodeState(node: NavNode, collapsed: ReadonlySet<string>): NavNode
416
453
  () => parseTargetFromSearchParams(nav.searchParams),
417
454
  [nav.searchParams],
418
455
  );
456
+ const activeMarker = useContext(ActiveScreenMarkerContext);
419
457
  const screenActive =
420
- node.screen !== undefined && nav.route?.screenId === lastSegment(node.screen);
458
+ node.screen !== undefined &&
459
+ activeMarker !== undefined &&
460
+ lastSegment(node.screen) === activeMarker.screenId;
461
+ const screenIsExactMatch = screenActive && activeMarker?.exact === true;
421
462
  const targetActive = node.target !== undefined && targetsEqual(node.target, activeTarget);
422
463
  const childNodes = node.provider === true ? (providerChildren ?? []) : node.children;
423
464
  const visibleChildNodes = filterActive
@@ -429,6 +470,7 @@ function useNavNodeState(node: NavNode, collapsed: ReadonlySet<string>): NavNode
429
470
  expandable,
430
471
  isExpanded,
431
472
  active: screenActive || targetActive,
473
+ ariaCurrent: screenIsExactMatch || targetActive,
432
474
  childNodes: visibleChildNodes,
433
475
  // Ein gefilterter Knoten verschwindet nur, wenn weder er selbst noch ein
434
476
  // sichtbar gebliebenes Kind matcht — sonst bliebe ein leerer Ordner-Header.
@@ -595,7 +637,7 @@ function NavMenuNode({ node, collapsed, onToggle }: NavSubProps): ReactNode {
595
637
  <SidebarMenuButton asChild isActive={s.active} tooltip={s.displayLabel}>
596
638
  <KumikoLink
597
639
  to={{ ...(s.workspaceId !== undefined && { workspaceId: s.workspaceId }), screenId }}
598
- {...(s.active && { "aria-current": "page" })}
640
+ {...(s.ariaCurrent && { "aria-current": "page" })}
599
641
  >
600
642
  <NavLeadingIcon node={node} active={s.active} label={s.displayLabel} />
601
643
  <span
@@ -715,7 +757,7 @@ function NavSubNode({ node, collapsed, onToggle }: NavSubProps): ReactNode {
715
757
  <SidebarMenuSubButton asChild isActive={s.active}>
716
758
  <KumikoLink
717
759
  to={{ ...(s.workspaceId !== undefined && { workspaceId: s.workspaceId }), screenId }}
718
- {...(s.active && { "aria-current": "page" })}
760
+ {...(s.ariaCurrent && { "aria-current": "page" })}
719
761
  >
720
762
  <NavLeadingIcon node={node} active={s.active} label={s.displayLabel} />
721
763
  <span
@@ -1,5 +1,5 @@
1
1
  import type { ScreenDefinition } from "@cosmicdrift/kumiko-framework/ui-types";
2
- import { lastSegment } from "./nav-tree";
2
+ import { lastSegment } from "@cosmicdrift/kumiko-renderer";
3
3
 
4
4
  export type BreadcrumbCrumb = {
5
5
  readonly label: string;
@@ -10,13 +10,38 @@ export function screenTitleKey(screenShortId: string): string {
10
10
  return `screen:${screenShortId}.title`;
11
11
  }
12
12
 
13
- export function resolveDetailBreadcrumb(
13
+ // Every screen type carrying `listScreenId` declares it identically — reading
14
+ // it here (instead of at each call site) keeps the switch the only place
15
+ // that has to grow when a new screen type adopts the field.
16
+ function explicitListScreenId(screen: ScreenDefinition): string | undefined {
17
+ switch (screen.type) {
18
+ case "custom":
19
+ case "projectionDetail":
20
+ case "entityEdit":
21
+ case "actionForm":
22
+ return screen.listScreenId;
23
+ default:
24
+ return undefined;
25
+ }
26
+ }
27
+
28
+ // Shared by the breadcrumb (this file) and NavTree's active-marker fallback
29
+ // (nav-tree.tsx) — both need "which list screen does this detail belong to",
30
+ // so this is the one place that answers it. An explicit `listScreenId` wins
31
+ // over the heuristics below (rowAction target / same-entity entityList): a
32
+ // screen author who declares it is opting out of the guess.
33
+ function resolveParentScreen(
14
34
  screens: readonly ScreenDefinition[],
15
- detailScreenId: string,
16
- t: (key: string) => string,
17
- ): readonly BreadcrumbCrumb[] | undefined {
18
- const detail = screens.find((s) => lastSegment(s.id) === detailScreenId);
19
- if (detail === undefined) return undefined;
35
+ detail: ScreenDefinition,
36
+ ): ScreenDefinition | undefined {
37
+ const detailScreenId = lastSegment(detail.id);
38
+
39
+ const listFromExplicit = ((): ScreenDefinition | undefined => {
40
+ const explicitId = explicitListScreenId(detail);
41
+ return explicitId !== undefined
42
+ ? screens.find((s) => lastSegment(s.id) === explicitId)
43
+ : undefined;
44
+ })();
20
45
 
21
46
  const listFromRowAction = screens.find((s) => {
22
47
  if (s.type !== "entityList") return false;
@@ -28,22 +53,31 @@ export function resolveDetailBreadcrumb(
28
53
  ? screens.find((s) => s.type === "entityList" && s.entity === detail.entity)
29
54
  : undefined;
30
55
 
31
- const listFromCustomParent =
32
- detail.type === "custom" && detail.listScreenId !== undefined
33
- ? screens.find((s) => lastSegment(s.id) === detail.listScreenId)
34
- : undefined;
56
+ return listFromExplicit ?? listFromRowAction ?? listFromEntity;
57
+ }
35
58
 
36
- // projectionDetail has no entity to pair with an entityList (unlike
37
- // entityEdit above) — `listScreenId` is its only back-navigation source.
38
- // Needed because RenderEdit's Cancel button is never wired up for this
39
- // screen type and isn't reachable via a listFromRowAction either.
40
- const listFromProjectionDetailParent =
41
- detail.type === "projectionDetail" && detail.listScreenId !== undefined
42
- ? screens.find((s) => lastSegment(s.id) === detail.listScreenId)
43
- : undefined;
59
+ /** The short id of {screenId}'s parent list screen, resolved via the same
60
+ * logic as `resolveDetailBreadcrumb` — `undefined` when nothing resolves
61
+ * (unknown screen, or no explicit/heuristic parent). */
62
+ export function resolveParentScreenId(
63
+ screens: readonly ScreenDefinition[],
64
+ screenId: string,
65
+ ): string | undefined {
66
+ const detail = screens.find((s) => lastSegment(s.id) === screenId);
67
+ if (detail === undefined) return undefined;
68
+ const parent = resolveParentScreen(screens, detail);
69
+ return parent !== undefined ? lastSegment(parent.id) : undefined;
70
+ }
71
+
72
+ export function resolveDetailBreadcrumb(
73
+ screens: readonly ScreenDefinition[],
74
+ detailScreenId: string,
75
+ t: (key: string) => string,
76
+ ): readonly BreadcrumbCrumb[] | undefined {
77
+ const detail = screens.find((s) => lastSegment(s.id) === detailScreenId);
78
+ if (detail === undefined) return undefined;
44
79
 
45
- const list =
46
- listFromRowAction ?? listFromEntity ?? listFromCustomParent ?? listFromProjectionDetailParent;
80
+ const list = resolveParentScreen(screens, detail);
47
81
  if (list === undefined) {
48
82
  return [{ label: t(screenTitleKey(detailScreenId)) }];
49
83
  }
@@ -25,6 +25,7 @@ import {
25
25
  type DataTableFacet,
26
26
  type DataTableProps,
27
27
  type FieldProps,
28
+ type FillContainerProps,
28
29
  type FormProps,
29
30
  type FormWidth,
30
31
  type GridCellProps,
@@ -903,6 +904,8 @@ function DefaultDataTable({
903
904
  onCellChange,
904
905
  getRowTestId,
905
906
  getCellTestId,
907
+ chromeless,
908
+ scrollBody,
906
909
  }: DataTableProps): ReactNode {
907
910
  // One locale/translate subscription per table — not per cell (fw#2345).
908
911
  // Optional hooks: a bare DataTable outside LocaleProvider must not crash.
@@ -935,7 +938,20 @@ function DefaultDataTable({
935
938
  // trägt den bg-muted-Grauton. `bg-card` (statt transparent) → die Liste
936
939
  // sitzt auf derselben Card-Fläche wie Forms; auf Themes mit farbigem
937
940
  // Page-Background (z.B. Cream) matchen Listen sonst nicht die Cards.
938
- <div className="overflow-hidden rounded-lg border bg-card">
941
+ // `chromeless` drops that frame for a host with its own boundary already (a tab panel, fw#2722).
942
+ // `scrollBody` fills the remaining height of its flex-col ancestor
943
+ // (see DefaultForm/FormScreenShell's `fillHeight` and this table's own
944
+ // outer wrapper below) and scrolls rows internally, instead of
945
+ // `overflow-hidden` (document-flow height, grows with row count) — for
946
+ // a host where a long list must not stretch the whole page (a tab
947
+ // panel, fw#2722). `min-h-0` overrides flex's default min-height:auto,
948
+ // which would otherwise let this grow past its flex-1 share to fit content.
949
+ <div
950
+ className={cn(
951
+ scrollBody === true ? "flex-1 min-h-0 overflow-y-auto" : "overflow-hidden",
952
+ chromeless !== true && "rounded-lg border bg-card",
953
+ )}
954
+ >
939
955
  <Table data-testid={testId}>
940
956
  <TableHeader className="bg-muted">
941
957
  <TableRow className="hover:bg-transparent">
@@ -1137,7 +1153,10 @@ function DefaultDataTable({
1137
1153
  return (
1138
1154
  <div
1139
1155
  data-testid={testId !== undefined ? `${testId}-cards` : "render-list-cards"}
1140
- className="flex flex-col gap-3"
1156
+ className={cn(
1157
+ "flex flex-col gap-3",
1158
+ scrollBody === true && "flex-1 min-h-0 overflow-y-auto",
1159
+ )}
1141
1160
  >
1142
1161
  {onSortChange !== undefined && sortableColumns.length > 0 && (
1143
1162
  <select
@@ -1239,7 +1258,7 @@ function DefaultDataTable({
1239
1258
  // der Tabelle im selben Padding-Block — kein separater bg-Bar, kein Screen-
1240
1259
  // Titel (der steht im Breadcrumb der Shell).
1241
1260
  return (
1242
- <div className="flex flex-col gap-4 p-6 w-full">
1261
+ <div className={cn("flex flex-col gap-4 p-6 w-full", scrollBody === true && "flex-1 min-h-0")}>
1243
1262
  {hasToolbar && (
1244
1263
  <div
1245
1264
  data-testid={testId !== undefined ? `${testId}-toolbar` : "render-list-toolbar"}
@@ -2132,6 +2151,7 @@ function DefaultForm({
2132
2151
  width,
2133
2152
  stickyActions,
2134
2153
  headerRegion,
2154
+ fillHeight,
2135
2155
  }: FormProps): ReactNode {
2136
2156
  // Eingebettet (AuthCard etc.): nacktes <form>, gestapelte Felder mit gap —
2137
2157
  // der Container trägt Card/Titel selbst, sonst Card-in-Card.
@@ -2162,12 +2182,25 @@ function DefaultForm({
2162
2182
  // between each other, muted action footer. Shell width defaults to full
2163
2183
  // (same chrome as lists); pass width to narrow (auth-adjacent / dense).
2164
2184
  return (
2165
- <FormRoot onSubmit={onSubmit} testId={testId} className="flex flex-col w-full">
2166
- <FormScreenShell {...(width !== undefined && { maxWidth: width })}>
2185
+ <FormRoot
2186
+ onSubmit={onSubmit}
2187
+ testId={testId}
2188
+ className={cn("flex flex-col w-full", fillHeight === true && "h-full min-h-0")}
2189
+ >
2190
+ <FormScreenShell
2191
+ {...(width !== undefined && { maxWidth: width })}
2192
+ {...(fillHeight === true && { fillHeight: true })}
2193
+ >
2167
2194
  {headerRegion !== undefined && (
2168
2195
  <div className="flex flex-col gap-6 mb-8">{headerRegion}</div>
2169
2196
  )}
2170
- <div className={cn(cardSurface(), "overflow-hidden")}>
2197
+ <div
2198
+ className={cn(
2199
+ cardSurface(),
2200
+ "overflow-hidden",
2201
+ fillHeight === true && "flex-1 min-h-0 flex flex-col",
2202
+ )}
2203
+ >
2171
2204
  {(title !== undefined || subtitle !== undefined) && (
2172
2205
  <div className={cn(cardHeaderBorder, "px-6 pb-4 pt-5")}>
2173
2206
  {title !== undefined && (
@@ -2201,6 +2234,7 @@ function DefaultForm({
2201
2234
  // safe-area, fw#2528) — widen further if a wizard step's last field
2202
2235
  // ever renders visibly clipped under three or more wrapped rows.
2203
2236
  stickyActions === true && "max-sm:pb-32",
2237
+ fillHeight === true && "flex-1 min-h-0",
2204
2238
  )}
2205
2239
  >
2206
2240
  <InsideFormContext.Provider value={true}>{children}</InsideFormContext.Provider>
@@ -2255,18 +2289,30 @@ export function FormScreenShell({
2255
2289
  className,
2256
2290
  testId,
2257
2291
  maxWidth,
2292
+ fillHeight,
2258
2293
  }: {
2259
2294
  readonly children: ReactNode;
2260
2295
  readonly className?: string;
2261
2296
  readonly testId?: string;
2262
2297
  readonly maxWidth?: FormScreenShellWidth;
2298
+ /** Stacks children in a `h-full` flex column instead of normal document
2299
+ * flow, so a `flex-1 min-h-0` child can claim the remaining height below
2300
+ * the others (fw#2722 — DefaultForm's tabs+relatedList case). Default
2301
+ * false: unchanged, content-sized height. */
2302
+ readonly fillHeight?: boolean;
2263
2303
  }): ReactNode {
2264
2304
  const contextWidth = useContext(ScreenWidthContext);
2265
2305
  const width = maxWidth ?? contextWidth;
2266
2306
  return (
2267
2307
  <div
2268
2308
  data-testid={testId}
2269
- className={cn(screenPaddingClassName, "w-full", screenWidthClassName[width], className)}
2309
+ className={cn(
2310
+ screenPaddingClassName,
2311
+ "w-full",
2312
+ screenWidthClassName[width],
2313
+ fillHeight === true && "h-full flex flex-col min-h-0",
2314
+ className,
2315
+ )}
2270
2316
  >
2271
2317
  {children}
2272
2318
  </div>
@@ -2374,6 +2420,14 @@ function DefaultSection({
2374
2420
  );
2375
2421
  }
2376
2422
 
2423
+ function DefaultFillContainer({ children, testId }: FillContainerProps): ReactNode {
2424
+ return (
2425
+ <div data-testid={testId} className="flex flex-1 min-h-0 flex-col">
2426
+ {children}
2427
+ </div>
2428
+ );
2429
+ }
2430
+
2377
2431
  function DefaultGrid({ columns, children, testId, maxRows }: GridProps): ReactNode {
2378
2432
  // "auto": content-sized items in a wrapping row (e.g. a metrics band of
2379
2433
  // self-sized tiles) instead of N equal-width, container-stretched tracks.
@@ -2629,4 +2683,5 @@ export const defaultPrimitives: CorePrimitives = {
2629
2683
  StatusBadge: DefaultStatusBadge,
2630
2684
  Metric: DefaultMetric,
2631
2685
  JsonView: DefaultJsonView,
2686
+ FillContainer: DefaultFillContainer,
2632
2687
  };