Skip to content

fix(storefront): toaster polish — theme, duration conflict, memoize options, richColors #1982

@filiphsps

Description

@filiphsps

What to build

providers-registry.tsx:83-95 configures sonner with three issues that hurt usability and consistency:

  1. theme="dark" is hard-coded. Toasts ignore prefers-color-scheme and the shop's design-token theme. Should default to "system" (or be wired into the shop theme) so light-mode users get appropriately-themed toasts.
  2. Duration conflict — top-level duration={5000} vs toastOptions.duration: 2500. Sonner uses the inner override, but the outer prop is dead-code that misleads readers. Pick one source of truth.
  3. toastOptions literal — passed as a fresh { duration: 2500, classNames: { toast: 'toast-notification' } } on every render. If ProvidersRegistry re-renders, Toaster sees a new prop reference. Hoist to a module-level constant or useMemo.
  4. No richColors — error vs success differentiation is icon-only. Add richColors for clearer success/warning/error distinction.
  5. a11y — verify aria-live and role="status" defaults are correctly applied (sonner handles this, but assert in test).

Acceptance criteria

  • Theme respects user preference (default "system" or shop-themed)
  • Single duration source of truth — pick one and remove the other
  • toastOptions reference is stable across re-renders
  • richColors enabled
  • Test asserts ARIA live-region attributes on rendered toast

Blocked by

None — can start immediately.

References

  • apps/storefront/src/components/providers-registry.tsx:83-95

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions