App-wide toasts: one ToastRegion for every layout, a documented API, and toasts across redirects
Maintainers usually reply within 2 days
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 35/100
- Issue type
- Feature
- Clarity
- Mostly clear
- Activity status
- Active
- Tech stack
- node.js, react, typescript
- Domain
- accessibility, backend, frontend
Research direction
Start with apps/aurora/app/root.tsx, packages/contents/routes/layout.tsx, and the existing queue and region in packages/layout/config/toast.ts and packages/layout/components/Toast/Toast.tsx. Read how setAuthOnResponse works in @plone/react-router before designing the redirect flash flow. Done means toasts render across layouts, redirect toasts appear once and do not return on reload, and screen-reader announcements remain supported.
Written by the indexing model from the issue text.
Description
Summary
Aurora has a global toast queue that any package or add-on can push to. The ToastRegion that renders that queue is mounted in one layout only, @plone/contents, so a toast raised anywhere else is queued and never shown. A loader or action that ends in a server redirect also has no way to carry a toast to the page it redirects to.
This issue proposes:
- Mounting the region once for the whole app.
- A small documented API for raising a toast.
- A flash mechanism that carries a toast across a redirect.
Where things are now
All links are at 1.0.0-alpha.16.
The queue. It is a module-level UNSTABLE_ToastQueue, registered as two utilities, toast/queue and toast/show. show adds an item with a fixed 25 s timeout.
packages/layout/config/toast.ts
The region. AppToast wraps UNSTABLE_ToastRegion.
packages/layout/components/Toast/Toast.tsx
Where it is mounted. Only in the contents layout:
packages/contents/routes/layout.tsx#L130
Who uses it:
ErrorToast, from the contents route'sErrorBoundary.- The Plate media upload toast.
- The contents provider.
What is not covered. The public layout (@plone/publicui/routes/index.tsx), the CMS layout (@plone/cmsui/routes/layout.tsx, which hosts the edit form, add form and control panels) and the root Layout mount no region. A toast/show call on any of those pages adds to a queue nothing renders.
There is also a second toast component, @plone/components' Toast: an icon, a title and content, with no queue or region. Two components with the same name, one of which is not connected to the queue, invite the wrong import.
Why it matters
Each of these needs feedback that survives a navigation, or that is raised on a page outside the contents view:
- Saving a control panel. #220 makes control panels saveable. "Saved" and "could not save" belong in a toast, but the control panel routes live in cmsui's layout, which has no region.
- Saving content. The edit and add forms are in cmsui's layout too.
- Add-ons explaining a redirect. This came up while porting
pas.plugins.identityto Aurora (collective/pas-plugins-identity#132). When a signed-in user's profile is missing required fields, the add-on holds them until it is complete:- Volto redirects to the profile's edit form and says why in a toast: "Please fill in Organisation, Country before you can continue."
- Aurora has no toast that reaches the edit form, so the add-on had to add a whole page (
/complete-profile) just to give that explanation (collective/pas-plugins-identity#139). - The same add-on shows "Access withdrawn" inline after withdrawing an OAuth application, where Volto uses a toast (collective/pas-plugins-identity#140).
- Server redirects. An action that succeeds and redirects, such as save then go to the view, or log in then go to
came_from, cannot say anything on the page it lands on. Today the only option is a query parameter that each destination page would have to know about.
Proposal
1. One region for the whole app
Mount AppToast once in the root Layout (apps/aurora/app/root.tsx#L175), inside <body>, and remove the one in the contents layout. The queue is already global, so every page then shows what any page raised. Because the queue lives in module scope, a toast raised just before a client-side navigation is shown on the next page.
A slot such as toasts, with AppToast as the default, would let a theme replace the region without forking the root.
2. A small documented API
The toast/show utility works, but its contract is undocumented, has one fixed timeout, and has no notion of kind. Something like this:
import { toast } from '@plone/layout/toast';
toast.success({ title: t('cmsui.controlpanel.saved') });
toast.error({ title: t('…'), description: error.message });
toast.info({ title: '…', timeout: 8000 }); // timeout optional; null = until dismissed
The proposed design:
- Built on the existing queue, with
classNamereplaced by akindthat the region styles and gives an icon to. - Exposed through the registry, keeping
toast/showworking as an alias for compatibility, so an add-on can call it without importing@plone/layoutdirectly. - Merged with the other
Toast.@plone/components'Toast(icon, title, content) could become the content renderer of this region, or be renamed.
3. Toasts across a server redirect (flash)
For a loader or action that redirects, a helper in @plone/react-router next to setAuthOnResponse:
return setToastOnResponse(redirect(next), {
kind: 'success',
title: 'Saved',
});
How it would work:
- Writing. The toast is stored in a short-lived, signed,
HttpOnlycookie, the way the auth cookie is. - Reading. The root loader reads it, returns it, and clears the cookie on the same response.
- Showing. The root component adds it to the queue on hydration and on each navigation where it appears.
This is the same pattern as Volto's addMessage and Plone Classic's status messages, without a store.
Acceptance
- A toast raised from any route is visible, whichever layout the page uses: public, cmsui, contents, or one an add-on registers.
- A toast set on a redirect response is shown once on the page the redirect lands on, and not again on reload.
- Errors are announced to screen readers. RAC's region already does this, and it should stay that way.
Related
These are other gaps found while porting pas.plugins.identity to Aurora, for context:
- Add-on endpoints on
@plone/client. #221 addsPloneClient.extend()and aclientEndpointsutility. Until it lands, the add-on calls its REST endpoints with its ownfetchhelper. - Saveable control panels. #220, which needs the feedback this issue is about.
- Filed since:
- plone/aurora#224: replacing a registered route.
- plone/aurora#225: adding routes under another add-on's layout.
- plone/aurora#226: add-on expansions of the content request.
- 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 ·