Skip to content

DeepSeek Harness Tauri 桌面版 | Only 8mb installer, zero environment setup, preset plugins, Windows / macOS / Linux.

fix(toast): 主窗口提示不再因 null children 静默丢失

hairyfebb113e3532b
diff --git a/src/components/toast-provider.tsx b/src/components/toast-provider.tsx
index cfee1869..da4efb37 100644
--- a/src/components/toast-provider.tsx
+++ b/src/components/toast-provider.tsx
@@ -15,6 +15,9 @@ interface ToastProviderProps {
/**
* 应用共用的 HeroUI queue/provider。桌宠窗口通过 custom 渲染精简气泡,
* 主窗口保留 HeroUI 默认的操作和关闭按钮。
+ *
+ * 非 custom 分支必须传 `undefined`:HeroUI 以 `typeof children === 'undefined'`
+ * 判定「用默认气泡」,传 `null` 会被当作「渲染空内容」而整条提示不落地。
*/
export function ToastProvider(props: ToastProviderProps) {
const [updates, setUpdates] = useState(() => new Map<string, ToastUpdateEvent['options']>())
@@ -62,7 +65,7 @@ export function ToastProvider(props: ToastProviderProps) {
</Toast>
)
}
- : null}
+ : undefined}
</Toast.Provider>
))}
{props.children}
diff --git a/test/toast-provider.test.ts b/test/toast-provider.test.ts
new file mode 100644
index 00000000..f76dc6a4
--- /dev/null
+++ b/test/toast-provider.test.ts
@@ -0,0 +1,24 @@
+import { readFileSync } from 'node:fs'
+import { describe, expect, it } from 'vitest'
+
+const PROVIDER = '../src/components/toast-provider.tsx'
+const HEROUI_TOAST = '../node_modules/@heroui/react/dist/components/toast/toast.js'
+
+function source(path: string): string {
+ return readFileSync(new URL(path, import.meta.url), 'utf8')
+}
+
+describe('toast provider render-slot contract', () => {
+ it('falls back to the HeroUI default bubble only for undefined children', () => {
+ // 独立 oracle:HeroUI 用 `typeof children === "undefined"` 判定走默认气泡,
+ // 传 null 会命中最后的 `: children` 分支渲染空内容。
+ expect(source(HEROUI_TOAST)).toContain('typeof children === "undefined"')
+ })
+
+ it('passes undefined — never null — on the non-custom branch', () => {
+ const provider = source(PROVIDER)
+ expect(provider).toContain('props.custom')
+ expect(provider).toContain(': undefined}')
+ expect(provider).not.toContain(': null}')
+ })
+})