Active form registry: preview the content being edited outside the form (inherited theme settings)
Maintainers usually reply within 2 days
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 15/100
- Issue type
- Feature
- Clarity
- Mostly clear
- Activity status
- Active
- Tech stack
- react, typescript
- Domain
- frontend
Research direction
Start with the form layer the issue builds on: FormProvider and useFormContext (#252), and the form store (#244), to see how per-field subscriptions work. The proposed ActiveFormProvider, useActiveForm and useInheritedSetting would live in @plone/helpers, and ContentForm would register itself. Resolve the four open questions before writing code; the issue names no existing file to edit.
Written by the indexing model from the issue text.
Description
Summary
Some components outside a form need to preview what's being edited, before it's saved. The typical case is a theme whose header, logo, footer or colors come from a behavior inherited down the content tree: a subsite sets its own logo and colors, and its children inherit them. While an editor changes them, the header should show the new values live.
Since #244, each form has its own store, reached through React context (FormProvider / useFormContext, #252). That only reaches components inside the form's subtree, and a header slot rendered by the layout is outside it. This issue proposes a small active form registry: an app-level pointer to the form being edited, with its identity. It's not a global copy of the form's data.
Prior art: Volto Light Theme
VLT (kitconcept/volto-light-theme) stores these settings in behaviors (voltolighttheme.header, voltolighttheme.theme, kitconcept.footer). It reads them through plone.restapi's inherit expander: content['@components'].inherit[behavior] gives data and from (the object it's inherited from).
For the live preview, its useLiveData hook and Theming component read Volto's Redux form.global, a copy of the whole content form. The copy has no identity, so each consumer re-derives whether the form values should win:
- add mode, detected from the URL (
pathname.endsWith('/add')); - whether the edited type has the behavior, by comparing the inherited keys with the form schema;
- whether you're adding directly inside the object that owns the inherited value, by comparing
from['@id']with the URL; errorContextas a fallback.
It works, but it's fragile. And since form.global changes on every keystroke, every consumer re-renders on every keystroke.
The distinction
- A global copy of the form data (Volto's
form.global, Aurora's formerformAtom) is the wrong tool: forms are per-instance, and a copy has no identity. - A global pointer to the active editing session is fine: there's one per app, like the toolbar.
Proposal
type ActiveForm = {
/** The form's store (#252): subscribe to single fields. */
form: FormApi<Content>;
/** The edited object's `@id`, or `undefined` when adding. */
id?: string;
/** Where the object is being added, when adding. */
parent?: string;
/** Whether the edited type provides a behavior, from its schema
* (plone.restapi sets `behavior` on each property). */
provides(behavior: string): boolean;
};
-
An
ActiveFormProviderat the app or layout level holds the currentActiveForm(ornull).useActiveForm()reads it. -
ContentFormregisters itself when it mounts and unregisters when it unmounts. Other forms (block settings, control panels, the recurrence modal) don't register, so it's always clear which form is "the content being edited". -
A resolver hook for inherited settings replaces VLT's heuristics with explicit checks:
// Conceptually; the real hook can't call hooks conditionally. function useInheritedSetting<T>(content, behavior: string, field: string): T { const inherited = content['@components']?.inherit?.[behavior]; const active = useActiveForm(); const editingSource = active?.provides(behavior) && (active.id === inherited?.from['@id'] || active.id === undefined); return editingSource ? useFieldValue(field) : inherited?.data[field]; }Case Result Editing the object that owns the setting the form's value, live Adding a new object that provides the behavior (e.g. a new subsite) the form's value, live Editing a child that only inherits the setting the inherited value Server rendering, or no form open the inherited value -
Re-renders: consumers subscribe per field through the form store, so a header re-renders only when a field it reads changes, not on every keystroke.
Both pieces live in @plone/helpers, next to the form layer. Themes (and VLT on Aurora) use the resolver hook instead of reading form data themselves.
Open questions
- Is the public header visible while editing? Today the edit route uses the CMS UI layout, so there's nothing to preview yet. This becomes relevant when editing happens inside the public layout. The blocks editor already renders inside
.content-area, so themes already style its content. - Colors are CSS custom properties: a theme component can set them on
:rootfrom the resolver, without restyling components. - Data: the
inheritexpansion has to be on the content request. Add-ons can declare it throughapiExpanders(#226). - Is it worth it? Without live preview, header and colors already update right after saving, because forms remount per item and React Router revalidates the loaders. That may be enough for logos; colors are where editors want to see changes before saving.
Related: #244 (form engine), #252 (form layer), #226 (apiExpanders).
- Dominant language
- JavaScript
- Stars
- 10
- Forks
- 9
- Avg merge
- 4d 7h
- Merged PRs (30d)
- 54
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from plone/aurora
-
01 type: bug 41 lvl: easy
Difficulty 1/5 1-3 hours Newbie friendliness 88/100
Maintainers usually reply within 2 days
-
Edit content TabList: selected tab's icon/label are hidden by its own selection indicator - a11yOpen01 type: bug 99 tag: UX Accessibility
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
Maintainers usually reply within 2 days
-
01 type: bug 30 needs: triage
Difficulty 1/5 Under an hour Newbie friendliness 90/100
Maintainers usually reply within 2 days
-
01 type: bug 99 tag: UX Accessibility
Difficulty 1/5 Under an hour Newbie friendliness 76/100
Maintainers usually reply within 2 days
-
01 type: bug 30 needs: triage
Difficulty 1/5 Under an hour Newbie friendliness 88/100
Maintainers usually reply within 2 days
Similar issues
-
accessibility bug dark-mode dashboards
Difficulty 1/5 Under an hour Newbie friendliness 84/100
quarto-dev/quarto-cli#15447 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
Difficulty 1/5 Under an hour Newbie friendliness 78/100
521xueweihan/HelloGitHub#4655 ·
-
[19.0] pos_sale: settling an order with a 0 down payment line crashes (reading 'reward_id') and leaves a wrong amount duePossibly taken A pull request linked to this issue is open or already merged. Open
Difficulty 2/5 1-3 hours Newbie friendliness 79/100
Maintainers usually reply within 1 day
-
bug CRIT-3
Difficulty 1/5 Under an hour Newbie friendliness 70/100
NASA-AMMOS/anms#426 ·