From 3cdd2b910e5427ec9cca66a128756a8b6e6cc767 Mon Sep 17 00:00:00 2001 From: Diego Diaz Date: Thu, 29 Oct 2026 21:12:25 -0500 Subject: [PATCH 1/3] =?UTF-8?q?docs(website):=20=F0=9F=93=9D=20document=20?= =?UTF-8?q?the=20fixes=20coming=20in=202.0.0-beta.2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The beta.1 known issues are gone: a Toaster or useSonner() first rendered on the client subscribes (and unsubscribes on unmount), topLayer works with several Toasters and comes back above modals, the theme listener follows the prop, and the type unions are exported. Also: classes.default only applies to toasts without a type, toast.getHistory() keeps up to 100 toasts, important and Action.actionButtonStyle are marked deprecated, and the behaviour now matches sonner 2.0.8. The one issue left is the dev-server stall with two toasts back to back. --- website/src/routes/docs/v2/advanced/index.tsx | 75 ++++++++----------- website/src/routes/docs/v2/index.tsx | 8 -- .../src/routes/docs/v2/migration/index.tsx | 2 +- website/src/routes/docs/v2/options/index.tsx | 7 +- website/src/routes/docs/v2/styling/index.tsx | 3 +- website/src/routes/docs/v2/toast/index.tsx | 4 +- 6 files changed, 40 insertions(+), 59 deletions(-) diff --git a/website/src/routes/docs/v2/advanced/index.tsx b/website/src/routes/docs/v2/advanced/index.tsx index c905d3f..873da09 100644 --- a/website/src/routes/docs/v2/advanced/index.tsx +++ b/website/src/routes/docs/v2/advanced/index.tsx @@ -45,12 +45,15 @@ const typesCode = `import type { ToastClassnames, ToastToDismiss, Action, -} from "qwik-sonner"; - -// Not exported yet — derive them from ToasterProps: -type Position = Extract; -type Theme = Extract; -type Direction = Extract;`; + Position, // "top-left" | "top-center" | … | "bottom-right" + Theme, // "light" | "dark" | "system" + Direction, // "rtl" | "ltr" | "auto" + SwipeDirection, // "top" | "right" | "bottom" | "left" + ToastTypes, + ToastIcons, + Offset, + PromiseData, +} from "qwik-sonner"; // the same from "qwik-sonner/headless"`; export default component$(() => { return ( @@ -65,7 +68,10 @@ export default component$(() => { toast() writes to a small module-level store, the same design as sonner. Each{" "} {""} subscribes to it in the browser once Qwik starts (on the{" "} qinit event), so the Toaster's code only loads when the page boots — not when - it scrolls into view — and toasts work even if it sits below the fold. + it scrolls into view — and toasts work even if it sits below the fold. A Toaster first + rendered in the browser (behind a condition, or after a {""} navigation) + subscribes as soon as it renders, picks up the toasts already showing, and unsubscribes when + it unmounts.

Toasts only exist in the browser. Server-side rendering always outputs an empty toaster. @@ -89,6 +95,14 @@ export default component$(() => {

  • Off by default, for parity with sonner.
  • No-op in browsers without the Popover API — it falls back to normal stacking.
  • +
  • + Each Toaster opens only while it has toasts of its own, so several can use{" "} + topLayer. +
  • +
  • + The browser stacks the top layer in opening order: if a modal opens while toasts are + showing, the Toaster's next toast brings it back above the modal. +
  • With the headless entry, add the{" "} popover reset yourself. @@ -100,8 +114,9 @@ export default component$(() => {

    useSonner()

    - A reactive list of the active toasts, for building your own renderer, a badge, or a log. It - subscribes when the component becomes visible. + A reactive list of the active toasts, for building your own renderer, a badge, or a log. + Like the Toaster, it subscribes once the page boots (or as soon as it renders in the + browser) and unsubscribes when the component unmounts.

    @@ -153,44 +168,14 @@ export default component$(() => {

    Known issues

    - Found in 2.0.0-beta.1. Each has a workaround; follow the{" "} - changelog for fixes. + The issues found in 2.0.0-beta.1 are fixed in 2.0.0-beta.2 — see the{" "} + changelog. One remains, in development only:

    - -

    - The subscription relies on qinit, which fires once when the page boots. A - Toaster that mounts later — behind a condition, or on a page reached through{" "} - {""} — misses it. Render the Toaster in the root layout. -

    -
    - -

    - Same cause: useSonner() subscribes on qvisible, which a - component mounted after boot (e.g. on a page reached through {""}) - doesn't receive, so its list stays empty until a full page load. -

    -
    - -

    - The browser stacks top-layer elements in the order they open, so a Toaster whose popover - is already open when a {"

    "} opens stays beneath it and toasts fired - from the dialog are hidden. In 2.0.0-beta.1 a topLayer Toaster also opens its - popover for toasts meant for other Toasters and, since it never renders them, never closes - it again. Use topLayer only with a single Toaster, and open modals while no - toasts are showing. -

    -
    - -

    - A Toaster that started with theme="system" keeps listening to OS changes - after its theme signal moves to light/dark (inherited from - sonner). If you switch themes at runtime, start from an explicit theme. -

    -
    - +

    - Position, Theme and Direction must be derived from{" "} - ToasterProps for now — see TypeScript. + With Qwik 2.0.0-beta.37's dev server, a plain toast() followed right away by + a typed one (toast.success()…), before the first has rendered, can stall the + Toaster until the page reloads. Production builds aren't affected.

    diff --git a/website/src/routes/docs/v2/index.tsx b/website/src/routes/docs/v2/index.tsx index 313aa7a..f55238c 100644 --- a/website/src/routes/docs/v2/index.tsx +++ b/website/src/routes/docs/v2/index.tsx @@ -123,14 +123,6 @@ export default component$(() => {

    - -

    - In 2.0.0-beta.1 a Toaster that is first rendered on the client — behind a - condition, or inside a page reached through {""} navigation — never - subscribes to the toast store, so its toasts don't show. Rendering it in the root layout - avoids this: it's server-rendered on first load and survives navigation. -

    -

    Styled or headless

    diff --git a/website/src/routes/docs/v2/migration/index.tsx b/website/src/routes/docs/v2/migration/index.tsx index 1630884..b440386 100644 --- a/website/src/routes/docs/v2/migration/index.tsx +++ b/website/src/routes/docs/v2/migration/index.tsx @@ -53,7 +53,7 @@ export default component$(() => { 1 dependency (DOMPurify) 0 dependencies sonner 1.x behaviour - sonner 2.0.7 behaviour + sonner 2.0.8 behaviour

    Steps

    diff --git a/website/src/routes/docs/v2/options/index.tsx b/website/src/routes/docs/v2/options/index.tsx index 9f6c42b..f6be44e 100644 --- a/website/src/routes/docs/v2/options/index.tsx +++ b/website/src/routes/docs/v2/options/index.tsx @@ -87,8 +87,9 @@ const OPTION_ROWS: PropRow[] = [ { name: "important", type: "boolean", + deprecated: true, description: - "Accepted for parity with sonner's types; it currently has no effect (sonner 2 announces every toast through the region's polite live region).", + 'No effect. In qwik-sonner 1.x it announced the toast with `aria-live="assertive"`; sonner 2 dropped it, and every toast is announced through the Toaster\'s polite live region.', }, ]; @@ -108,7 +109,9 @@ const ACTION_ROWS: PropRow[] = [ { name: "actionButtonStyle", type: "CSSProperties", - description: "Typed for parity; style buttons through the toast's `actionButtonStyle`.", + deprecated: true, + description: + "No effect, as in sonner. Style the buttons with the toast's `actionButtonStyle` / `cancelButtonStyle` or the Toaster's `toastOptions`.", }, ]; diff --git a/website/src/routes/docs/v2/styling/index.tsx b/website/src/routes/docs/v2/styling/index.tsx index fd3d9de..e25a549 100644 --- a/website/src/routes/docs/v2/styling/index.tsx +++ b/website/src/routes/docs/v2/styling/index.tsx @@ -22,7 +22,8 @@ const CLASS_ROWS: PropRow[] = [ { name: "default", type: "ClassList", - description: "Added to every toast `
  • `, whatever its type (same as sonner).", + description: + "Added to the toast `
  • ` when it has no type: `toast()`, `toast.message()` and `toast.custom()` (same as sonner).", }, ]; diff --git a/website/src/routes/docs/v2/toast/index.tsx b/website/src/routes/docs/v2/toast/index.tsx index 8b9e3fb..dcb8517 100644 --- a/website/src/routes/docs/v2/toast/index.tsx +++ b/website/src/routes/docs/v2/toast/index.tsx @@ -15,7 +15,7 @@ toast.promise(promise, data) // loading → success / error toast.custom((id) => jsx, options?) toast.dismiss(id?) // one toast, or all of them toast.getToasts() // active toasts -toast.getHistory() // everything created so far`; +toast.getHistory() // created so far (up to 100)`; const typesCode = `toast("Event has been created"); @@ -97,7 +97,7 @@ toast.dismiss(id); // remove one toast toast.dismiss(); // remove every toast`; const stateCode = `toast.getToasts(); // toasts currently on screen (not dismissed) -toast.getHistory(); // every toast created so far, including dismissed ones`; +toast.getHistory(); // toasts created so far, dismissed ones included (up to 100)`; const PROMISE_ROWS: PropRow[] = [ { From 80ac4b6288ffd5a295727efb0bca834d453ba6f8 Mon Sep 17 00:00:00 2001 From: Diego Diaz Date: Thu, 29 Oct 2026 21:12:25 -0500 Subject: [PATCH 2/3] =?UTF-8?q?refactor(website):=20=E2=99=BB=EF=B8=8F=20d?= =?UTF-8?q?rop=20the=202.0.0-beta.1=20workarounds=20from=20the=20demos?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The dialog demo no longer closes the top-layer popover before opening the modal, the counter demo loses its reload hint, and the site imports Position and Theme from qwik-sonner instead of deriving them. --- website/src/lib/toaster-context.ts | 11 ++++------- website/src/routes/docs/v2/examples/index.tsx | 18 +++--------------- 2 files changed, 7 insertions(+), 22 deletions(-) diff --git a/website/src/lib/toaster-context.ts b/website/src/lib/toaster-context.ts index b76eb76..e4622ba 100644 --- a/website/src/lib/toaster-context.ts +++ b/website/src/lib/toaster-context.ts @@ -1,9 +1,7 @@ import { createContextId, useContext, type Signal } from "@qwik.dev/core"; -import type { ToasterProps } from "qwik-sonner"; +import type { Position, Theme } from "qwik-sonner"; -// qwik-sonner doesn't export these unions yet, so derive them from the props. -export type Position = Extract, string>; -export type Theme = Extract, string>; +export type { Position, Theme }; export const POSITIONS: Position[] = [ "top-left", @@ -16,9 +14,8 @@ export const POSITIONS: Position[] = [ /** * Live settings of the site-wide `` rendered in the root layout. Demos - * on any page write to these signals instead of rendering their own Toaster: - * a Toaster that is first rendered on the client (e.g. after a `` - * navigation) never subscribes in qwik-sonner 2.0.0-beta.1. + * on any page write to these signals instead of rendering their own Toaster, + * so every toast on the site comes from the same one. */ export interface ToasterControls { position: Signal; diff --git a/website/src/routes/docs/v2/examples/index.tsx b/website/src/routes/docs/v2/examples/index.tsx index 6246b5d..1186a5c 100644 --- a/website/src/routes/docs/v2/examples/index.tsx +++ b/website/src/routes/docs/v2/examples/index.tsx @@ -191,19 +191,7 @@ const DialogDemo = component$(() => { return ( <> - @@ -331,7 +319,7 @@ export default component$(() => { {".showModal()"} lives in the browser's top layer, above any z-index. A Toaster with topLayer joins it there.

    - + @@ -362,7 +350,7 @@ toast.info("Maintenance tonight", { toasterId: "announcements" });`} />

    Live toast counter

    - +