diff --git a/.changeset/37444-list-route-defers-authoring.md b/.changeset/37444-list-route-defers-authoring.md
new file mode 100644
index 00000000000..be1e1fffc56
--- /dev/null
+++ b/.changeset/37444-list-route-defers-authoring.md
@@ -0,0 +1,13 @@
+---
+'@object-ui/app-shell': patch
+'@objectstack/console': patch
+---
+
+perf(app-shell): an object list stops loading the package ask, the view settings panel and the create-view dialog before its first screen
+
+Clause-②: no
+Metadata-protocol: none
+
+An object list page fetched about 183 KB (brotli) of authoring code before its first screen, though it only needs that code when someone opens it. Three pieces did this. The "pick or create a package" ask that a view create may open was drawn closed on every list, and it brought in the package page's create dialog, its form and the Studio strings. The view settings panel and the create-view dialog were also drawn closed on every list. Now each one loads the first time it is opened, and after that it stays mounted, so closing it works as before. When a view create is refused, the reason loads with the refusal, and its toast shows once those strings arrive.
+
+Nothing a user sees or saves changes, apart from a short wait the first time one of these opens. Nothing to migrate.
diff --git a/ui/packages/app-shell/src/views/ObjectView.readOnlyPackageViewSaves-35974.test.tsx b/ui/packages/app-shell/src/views/ObjectView.readOnlyPackageViewSaves-35974.test.tsx
index 3923624e214..843eee170cb 100644
--- a/ui/packages/app-shell/src/views/ObjectView.readOnlyPackageViewSaves-35974.test.tsx
+++ b/ui/packages/app-shell/src/views/ObjectView.readOnlyPackageViewSaves-35974.test.tsx
@@ -273,9 +273,13 @@ describe('objectstack#35974 — a read-only package\'s view: no Delete, a read-o
expect(panelProps.current?.readOnly).toBe(false);
});
+ // objectstack#37444: the panel mounts the first time it is opened, so the
+ // cases below that read the open view's panel open it, through that view's
+ // own row (the door that opens the panel on a given view).
it('the panel opens on the shipped view read-only', async () => {
mount(SHIPPED.name);
await settle();
+ await clickConfig(SHIPPED.name);
await waitFor(() => expect(panelProps.current?.activeView?.id).toBe(SHIPPED.name));
await waitFor(() => expect(panelProps.current?.readOnly).toBe(true));
});
@@ -283,15 +287,18 @@ describe('objectstack#35974 — a read-only package\'s view: no Delete, a read-o
it('the panel on a shared view saved into the customization package is not read-only', async () => {
mount(CUSTOM.name);
await settle();
+ await clickConfig(CUSTOM.name);
await waitFor(() => expect(panelProps.current?.activeView?.id).toBe(CUSTOM.name));
expect(panelProps.current?.readOnly).toBe(false);
});
- it('on the reader\'s own view the panel is not read-only and Manage views is unchanged', async () => {
+ it('on the reader\'s own view the closed panel is not mounted and Manage views is unchanged', async () => {
mount(PERSONAL.id);
await settle();
- await waitFor(() => expect(panelProps.current?.activeView?.id).toBe(PERSONAL.id));
- expect(panelProps.current?.readOnly).toBe(false);
+ // objectstack#37444: closed, the panel is not mounted at all (it used to be,
+ // and this case read the verdict a closed panel was handed). Its own view is
+ // no row of Manage views, so no row opens the panel on it.
+ expect(panelProps.current).toBeNull();
// My views are no row of Manage views; the shared rows are judged as ever.
expect(screen.queryByTestId(`manage-views-row-${PERSONAL.id}`)).toBeNull();
await waitFor(async () => expect(await rowOffers(SHIPPED.name)).toEqual(FACTORY_OFFERS));
@@ -304,6 +311,8 @@ describe('objectstack#35974 — a read-only package\'s view: no Delete, a read-o
await settle();
await waitFor(() => expect(screen.getByTestId(`manage-views-row-${SHIPPED.name}`)).toBeTruthy());
expect(await rowOffers(SHIPPED.name)).toEqual(OFFERED);
+ await clickConfig(SHIPPED.name);
+ await waitFor(() => expect(panelProps.current?.open).toBe(true));
expect(panelProps.current?.readOnly).toBe(false);
});
@@ -313,6 +322,8 @@ describe('objectstack#35974 — a read-only package\'s view: no Delete, a read-o
await settle();
await waitFor(() => expect(screen.getByTestId(`manage-views-row-${SHIPPED.name}`)).toBeTruthy());
expect(await rowOffers(SHIPPED.name)).toEqual(OFFERED);
+ await clickConfig(SHIPPED.name);
+ await waitFor(() => expect(panelProps.current?.open).toBe(true));
expect(panelProps.current?.readOnly).toBe(false);
});
});
diff --git a/ui/packages/app-shell/src/views/ObjectView.tsx b/ui/packages/app-shell/src/views/ObjectView.tsx
index ac9e9bc4207..35cd99e333b 100644
--- a/ui/packages/app-shell/src/views/ObjectView.tsx
+++ b/ui/packages/app-shell/src/views/ObjectView.tsx
@@ -43,8 +43,9 @@ import { MetadataPanel, useMetadataInspector } from './MetadataInspector.js';
// objectstack#33293: the view config panel loads with the first list, not with
// the console. Statically, it held the view-variant inspector, `SchemaForm` and
// the Studio form widgets in the EAGER closure, so a dashboard route downloaded
-// them too. It is drawn on every list (closed, it draws nothing), so its chunk
-// is fetched as the list mounts, before any admin can open it.
+// them too. objectstack#37444: it mounts the first time it is opened, not with
+// every list, so the list's first screen no longer fetches it (see
+// `useOpenedOnce` below).
const ViewConfigPanel = lazy(() =>
import('./ViewConfigPanel.js').then((m) => ({ default: m.ViewConfigPanel })),
);
@@ -53,9 +54,24 @@ import { dropPublishedViewList } from './metadata-admin/viewListDrop.js';
// objectstack#33582: the create-view dialog loads with the first list, as the
// view config panel above does. Statically, it held the dataset catalogue and,
// through it, the Studio `en` string namespace in the EAGER closure.
+// objectstack#37444: like the panel, it mounts on its first opening.
const CreateViewDialog = lazy(() =>
import('./CreateViewDialog.js').then((m) => ({ default: m.CreateViewDialog })),
);
+
+/**
+ * objectstack#37444 — `true` from the first render `open` is, and from then on.
+ * A lazy panel or dialog behind it loads only when someone opens it (closed, it
+ * draws nothing, so mounting it with every list only fetched its chunk before
+ * the list's first screen), and stays mounted after, so closing it animates and
+ * keeps its state as before. The state is adjusted during render, React's way of
+ * deriving state from a prop, so the opening render already mounts it.
+ */
+function useOpenedOnce(open: boolean): boolean {
+ const [opened, setOpened] = useState(open);
+ if (open && !opened) setOpened(true);
+ return opened || open;
+}
import {
usePreviewDrafts,
} from '../preview/PreviewModeContext.js';
@@ -308,6 +324,8 @@ function ObjectViewInner({ dataSource, objects, onEdit, externalRefreshKey }: Co
// refuses with 403. `isAdmin` alone still gates what only reads.
const canAuthorMetadata = useCanAuthorMetadata();
const canManageViews = mayManageViews(isAdmin, canAuthorMetadata);
+ const viewConfigPanelMounted = useOpenedOnce(showViewConfigPanel && canManageViews);
+ const createViewDialogMounted = useOpenedOnce(showCreateViewDialog && canManageViews);
// Get Object Definition. The outer ObjectView wrapper already guards the
// missing-object case, so this always resolves while this component is
@@ -1710,7 +1728,7 @@ function ObjectViewInner({ dataSource, objects, onEdit, externalRefreshKey }: Co
showViewConfigPanel && canManageViews ? 'max-w-[280px] opacity-100' : 'max-w-0 opacity-0'
}`}
>
-
+ {viewConfigPanelMounted && { setShowViewConfigPanel(false); setViewConfigPanelMode('edit'); }}
@@ -1725,9 +1743,9 @@ function ObjectViewInner({ dataSource, objects, onEdit, externalRefreshKey }: Co
onAfterChange={handleDraftBarChange}
readOnly={viewConfigPanelReadOnly}
/>
-
+ }
-
+ {createViewDialogMounted && handleViewCreate(cfg)}
/>
-
+ }
{ if (!open) setPersonalViewDialog(null); }}
diff --git a/ui/packages/app-shell/src/views/ObjectView.viewConfigSaveWiring-10210.test.tsx b/ui/packages/app-shell/src/views/ObjectView.viewConfigSaveWiring-10210.test.tsx
index de66d7dfa6f..29bb97dec32 100644
--- a/ui/packages/app-shell/src/views/ObjectView.viewConfigSaveWiring-10210.test.tsx
+++ b/ui/packages/app-shell/src/views/ObjectView.viewConfigSaveWiring-10210.test.tsx
@@ -21,7 +21,7 @@
import * as React from 'react';
import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';
-import { render, cleanup, act, screen, fireEvent } from '@testing-library/react';
+import { render, cleanup, act, screen, fireEvent, waitFor } from '@testing-library/react';
import { MemoryRouter, Routes, Route } from 'react-router-dom';
import { ViewMetadataSchema } from '@objectstack/spec/ui';
@@ -116,6 +116,27 @@ vi.mock('./ViewConfigPanel', () => {
// The view's source reaches a dynamic import of `@objectstack/lint`: pay its
// load at collection, never inside a case's clocked window (`check:test-source-alias`).
+// objectstack#37444: the list's Settings view action, drawn beside the real
+// plugin view (whose own view switcher the console hides), so a case can open
+// the panel the way the action does.
+vi.mock('@object-ui/plugin-view', async (importOriginal) => {
+ const actual = await importOriginal();
+ const Real = actual.ObjectView;
+ return {
+ ...actual,
+ ObjectView: (props: React.ComponentProps) => (
+ <>
+