refactor: align Toast API with severity and accessory#1143
Conversation
📖 Storybook Preview |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Autofix Details
Bugbot Autofix prepared a fix for the issue found in the latest run.
- ✅ Fixed: Nested prop bag type exported from entrypoint
- Removed ToastCloseButtonProps from Toast entrypoint and package barrel to avoid exporting nested prop bag types.
Or push these changes by commenting:
@cursor push 5a49edaeab
Preview (5a49edaeab)
diff --git a/packages/design-system-react-native/src/components/Toast/index.ts b/packages/design-system-react-native/src/components/Toast/index.ts
--- a/packages/design-system-react-native/src/components/Toast/index.ts
+++ b/packages/design-system-react-native/src/components/Toast/index.ts
@@ -4,7 +4,6 @@
ToastOptions,
ToastProps,
ToastRef,
- ToastCloseButtonProps,
} from './Toast.types';
export {
TOAST_VISIBILITY_DURATION,
diff --git a/packages/design-system-react-native/src/components/index.ts b/packages/design-system-react-native/src/components/index.ts
--- a/packages/design-system-react-native/src/components/index.ts
+++ b/packages/design-system-react-native/src/components/index.ts
@@ -218,7 +218,6 @@
ToastOptions,
ToastProps,
ToastRef,
- ToastCloseButtonProps,
} from './Toast';
export { ButtonHero, ButtonHeroSize } from './ButtonHero';You can send follow-ups to the cloud agent here.
📖 Storybook Preview |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
There are 2 total unresolved issues (including 1 from previous review).
Autofix Details
Bugbot Autofix prepared a fix for the issue found in the latest run.
- ✅ Fixed: ToastOptions-only props leak to native View
- Updated Toaster to destructure and omit hasNoTimeout and bottomOffset before spreading props into Toast, preventing these non-view props from propagating to native views.
Or push these changes by commenting:
@cursor push dce7216943
Preview (dce7216943)
diff --git a/packages/design-system-react-native/src/components/Toast/Toaster.tsx b/packages/design-system-react-native/src/components/Toast/Toaster.tsx
--- a/packages/design-system-react-native/src/components/Toast/Toaster.tsx
+++ b/packages/design-system-react-native/src/components/Toast/Toaster.tsx
@@ -153,6 +153,13 @@
return null;
}
+ // Strip ToastOptions-only fields so they don't propagate to native views.
+ const {
+ hasNoTimeout: _omitHasNoTimeout,
+ bottomOffset: _omitBottomOffset,
+ ...toastRenderableProps
+ } = toastOptions;
+
return (
<Animated.View
onLayout={onAnimatedViewLayout}
@@ -160,7 +167,7 @@
{...props}
>
<Toast
- {...toastOptions}
+ {...toastRenderableProps}
onClose={() => {
closeToast();
toastOptions.onClose?.();You can send follow-ups to the cloud agent here.
📖 Storybook Preview |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 3 potential issues.
There are 5 total unresolved issues (including 2 from previous reviews).
Autofix Details
Bugbot Autofix prepared fixes for all 3 issues found in the latest run.
- ✅ Fixed: Toast leaks
hasNoTimeoutandbottomOffsetto native View- Filtered out
hasNoTimeoutandbottomOffsetin Toaster before forwarding props to Toast, preventing them from reaching native views.
- Filtered out
- ✅ Fixed:
ToastSharedPropsexported as unnecessary public API- Removed
ToastSharedPropsfrom the Toast entrypoint and the components barrel exports.
- Removed
- ✅ Fixed: Raw View with inline styles in stories
- Replaced
<View style={{ gap: 8 }}>with<Box gap={2}>in the Toast story to use design tokens.
- Replaced
Or push these changes by commenting:
@cursor push 5bb99bb309
Preview (5bb99bb309)
diff --git a/packages/design-system-react-native/src/components/Toast/Toast.stories.tsx b/packages/design-system-react-native/src/components/Toast/Toast.stories.tsx
--- a/packages/design-system-react-native/src/components/Toast/Toast.stories.tsx
+++ b/packages/design-system-react-native/src/components/Toast/Toast.stories.tsx
@@ -1,6 +1,6 @@
import type { Meta, StoryObj } from '@storybook/react-native';
import React from 'react';
-import { View } from 'react-native';
+import { Box } from '../Box';
// External dependencies.
import { Icon, IconColor, IconName, IconSize } from '../Icon';
@@ -62,12 +62,12 @@
export const Severity: Story = {
render: (args) => (
- <View style={{ gap: 8 }}>
+ <Box gap={2}>
<Toast {...args} severity={ToastSeverity.Default} text="Default" />
<Toast {...args} severity={ToastSeverity.Success} text="Success" />
<Toast {...args} severity={ToastSeverity.Warning} text="Warning" />
<Toast {...args} severity={ToastSeverity.Error} text="Error" />
- </View>
+ </Box>
),
args: {
description: 'Severity controls the default start accessory icon.',
diff --git a/packages/design-system-react-native/src/components/Toast/Toaster.tsx b/packages/design-system-react-native/src/components/Toast/Toaster.tsx
--- a/packages/design-system-react-native/src/components/Toast/Toaster.tsx
+++ b/packages/design-system-react-native/src/components/Toast/Toaster.tsx
@@ -120,6 +120,13 @@
return null;
}
+ // Filter out internal-only options that should not reach native views.
+ const {
+ hasNoTimeout: _ignoredHasNoTimeout,
+ bottomOffset: _ignoredBottomOffset,
+ ...toastForwardProps
+ } = toastOptions;
+
const onAnimatedViewLayout = (e: LayoutChangeEvent) => {
const { height } = e.nativeEvent.layout;
const translateYToValue = -(TOAST_BOTTOM_PADDING + bottomNotchSpacing);
@@ -155,7 +162,7 @@
{...props}
>
<Toast
- {...toastOptions}
+ {...toastForwardProps}
onClose={() => {
closeToast();
toastOptions.onClose?.();
diff --git a/packages/design-system-react-native/src/components/Toast/index.ts b/packages/design-system-react-native/src/components/Toast/index.ts
--- a/packages/design-system-react-native/src/components/Toast/index.ts
+++ b/packages/design-system-react-native/src/components/Toast/index.ts
@@ -5,7 +5,6 @@
ToastOptions,
ToastProps,
ToastCloseButtonProps,
- ToastSharedProps,
ToasterProps,
ToasterRef,
} from './Toast.types';
diff --git a/packages/design-system-react-native/src/components/index.ts b/packages/design-system-react-native/src/components/index.ts
--- a/packages/design-system-react-native/src/components/index.ts
+++ b/packages/design-system-react-native/src/components/index.ts
@@ -218,7 +218,6 @@
ToastOptions,
ToastProps,
ToastCloseButtonProps,
- ToastSharedProps,
ToasterProps,
ToasterRef,
} from './Toast';You can send follow-ups to the cloud agent here.
457e582 to
8901809
Compare
📖 Storybook Preview |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 3 potential issues.
There are 4 total unresolved issues (including 1 from previous review).
Autofix Details
Bugbot Autofix prepared fixes for all 3 issues found in the latest run.
- ✅ Fixed: Toaster silently drops toast options'
twClassNameToasternow passestwClassName={toastProps.twClassName ?? twClassName}so per-toast classes are preserved.
- ✅ Fixed:
toast.dismiss()error message incorrectly saystoast.hide()- Added
'dismiss'to the method union, updated error message construction, andtoast.dismissnow reportstoast.dismiss()correctly.
- Added
- ✅ Fixed:
ToastCloseButtonPropsis exported but never used- Removed the unused
ToastCloseButtonPropsexport fromToast.types.ts.
- Removed the unused
Or push these changes by commenting:
@cursor push a1d31fff68
Preview (a1d31fff68)
diff --git a/packages/design-system-react-native/src/components/Toast/Toast.types.ts b/packages/design-system-react-native/src/components/Toast/Toast.types.ts
--- a/packages/design-system-react-native/src/components/Toast/Toast.types.ts
+++ b/packages/design-system-react-native/src/components/Toast/Toast.types.ts
@@ -23,13 +23,6 @@
export type ToastIconProps = Omit<IconProps, 'name' | 'size' | 'color'>;
/**
- * Optional props for the close `ButtonIcon`.
- */
-export type ToastCloseButtonProps = NonNullable<
- BannerBaseProps['closeButtonProps']
->;
-
-/**
* Shared toast props aligned with BannerBase, plus optional severity/icon props.
*/
export type ToastSharedProps = BannerBaseProps & {
diff --git a/packages/design-system-react-native/src/components/Toast/Toaster.tsx b/packages/design-system-react-native/src/components/Toast/Toaster.tsx
--- a/packages/design-system-react-native/src/components/Toast/Toaster.tsx
+++ b/packages/design-system-react-native/src/components/Toast/Toaster.tsx
@@ -39,12 +39,11 @@
let registeredRef: RefObject<ToasterRef> | null = null;
-const assertRegisteredRef = (method: 'hide' | 'show' | 'toast'): ToasterRef => {
+const assertRegisteredRef = (
+ method: 'hide' | 'show' | 'toast' | 'dismiss',
+): ToasterRef => {
if (!registeredRef?.current) {
- const invocation =
- method === 'toast'
- ? 'toast()'
- : `toast.${method === 'hide' ? 'hide' : 'show'}()`;
+ const invocation = method === 'toast' ? 'toast()' : `toast.${method}()`;
throw new Error(
`${invocation} called before <Toaster /> mounted. Render <Toaster /> once at the root of your app.`,
);
@@ -175,7 +174,7 @@
closeToast();
toastOnClose?.();
}}
- twClassName={twClassName}
+ twClassName={toastProps.twClassName ?? twClassName}
/>
</Animated.View>
);
@@ -205,5 +204,5 @@
};
toast.dismiss = () => {
- assertRegisteredRef('hide').closeToast();
+ assertRegisteredRef('dismiss').closeToast();
};You can send follow-ups to the cloud agent here.
📖 Storybook Preview |
📖 Storybook Preview |
📖 Storybook Preview |
📖 Storybook Preview |
📖 Storybook Preview |
📖 Storybook Preview |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
There are 3 total unresolved issues (including 2 from previous reviews).
Autofix Details
Bugbot Autofix prepared a fix for the issue found in the latest run.
- ✅ Fixed: Rest props spread overrides Toast's hardcoded visual identity
- Moved {...props} before explicit props so component-owned defaults and onClose nullification cannot be overridden.
Or push these changes by commenting:
@cursor push eccfc114b1
Preview (eccfc114b1)
diff --git a/packages/design-system-react-native/src/components/Toast/Toast.tsx b/packages/design-system-react-native/src/components/Toast/Toast.tsx
--- a/packages/design-system-react-native/src/components/Toast/Toast.tsx
+++ b/packages/design-system-react-native/src/components/Toast/Toast.tsx
@@ -73,6 +73,7 @@
return (
<BannerBase
{...actionProps}
+ {...props}
backgroundColor={BoxBackgroundColor.BackgroundSection}
borderColor={BoxBorderColor.BorderMuted}
borderWidth={1}
@@ -97,7 +98,6 @@
title={title}
titleProps={titleProps}
twClassName={twClassName ? `rounded-xl ${twClassName}` : 'rounded-xl'}
- {...props}
/>
);
};You can send follow-ups to the cloud agent here.
📖 Storybook Preview |
📖 Storybook Preview |
📖 Storybook Preview |
| @@ -3,129 +3,143 @@ | |||
| Toast is a component that slides up from the bottom of the screen. It is typically used to show post-confirmation information such as account switches, network changes, or transaction confirmations. | |||
There was a problem hiding this comment.
A bit hard to read from the changes, Toast has a slightly different readme template as it's not a typical jsx component. We need to communicate setup and the toast() api
docs720.mov
📖 Storybook Preview |
| example: ({ severity, title, description, actionButton }) => { | ||
| const resolvedActionButtonLabel = actionButton?.label || undefined; | ||
|
|
||
| return ( |
There was a problem hiding this comment.
The mapped Figma node is still the visual Toast surface, but the example intentionally shows Toaster plus toast(...) because that is the consumer-facing runtime API we want Dev Mode readers to copy into app code.
|
|
||
| useImperativeHandle(ref, () => innerRef.current as ToasterRef); | ||
|
|
||
| useLayoutEffect(() => { |
There was a problem hiding this comment.
useLayoutEffect keeps the imperative API registered before sibling passive mount effects run, which avoids a mount-time race when an app calls toast() during initial render effects.
|
|
||
| <!-- TODO: Replace 0.x.0 with the actual next released version when this Toast follow-up ships. --> | ||
|
|
||
| ### From version 0.23.0 to 0.x.0 |
There was a problem hiding this comment.
This migration section is separate from the earlier Toast migration because 0.23.0 already shipped the first API shape to consumers. Reviewers should treat this as a second breaking follow-up, not just unreleased cleanup on top of #1104.
There was a problem hiding this comment.
But I don't think we started to use Toast component anywhere yet?..
Would it make sense to re-phrase current migration API? Because basic migration path + specific changes for 0.23..0.24 make more cognitive load. And since we released, but didn't start to use the new component I think it's fine just silently re-write the existing migration documentation 🤫
| style={baseStyle} | ||
| {...props} | ||
| > | ||
| {actionButtonLabel && actionButtonOnPress ? ( |
There was a problem hiding this comment.
The explicit action-button branch here is mostly for type safety: BannerBase models action props as a union, so narrowing before render lets Toaster preserve label-only toast options without widening every Toast call site.
📖 Storybook Preview |
| ToastRef, | ||
| ToastLabelOptions, | ||
| ToastDescriptionOptions, | ||
| ToastLinkButtonOptions, | ||
| ToastCloseButtonOptions, |
There was a problem hiding this comment.
Removing imports of unused and unnecessary types
| @@ -1,9 +1,18 @@ | |||
| // External dependencies. | |||
| import { IconAlertSeverity } from '@metamask/design-system-shared'; | |||
| import { AnimationDuration } from '@metamask/design-tokens'; | |||
There was a problem hiding this comment.
Importing IconAlertSeverity for IconAlert usage
| export const TOAST_SEVERITY_ICON_MAP = { | ||
| [ToastSeverity.Success]: IconAlertSeverity.Success, | ||
| [ToastSeverity.Warning]: IconAlertSeverity.Warning, | ||
| [ToastSeverity.Danger]: IconAlertSeverity.Error, |
There was a problem hiding this comment.
Here we are mapping Danger to Error as we will be consolidating to Danger moving forward
| toast({ | ||
| severity, | ||
| title, | ||
| description, | ||
| actionButtonLabel: resolvedActionButtonLabel, | ||
| actionButtonOnPress: resolvedActionButtonLabel | ||
| ? () => undefined | ||
| : undefined, | ||
| }); | ||
| }} |
There was a problem hiding this comment.
Code connect file looks a little different from usual as we need to map it to the toast() function
2999ee4 to
5eb5853
Compare
📖 Storybook Preview |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix prepared a fix for the issue found in the latest run.
- ✅ Fixed:
closeButtonProps.onPresssilently ignored due to BannerBase early-return- Updated React Native BannerBase handleClosePress to invoke both onClose and closeButtonProps.onPress so the consumer handler is no longer ignored.
Or push these changes by commenting:
@cursor push 7866573597
Preview (7866573597)
diff --git a/packages/design-system-react-native/src/components/BannerBase/BannerBase.tsx b/packages/design-system-react-native/src/components/BannerBase/BannerBase.tsx
--- a/packages/design-system-react-native/src/components/BannerBase/BannerBase.tsx
+++ b/packages/design-system-react-native/src/components/BannerBase/BannerBase.tsx
@@ -55,10 +55,9 @@
const handleClosePress =
onClose || closeButtonPropsOnPress
? (event: GestureResponderEvent) => {
- if (onClose) {
- onClose();
- return;
- }
+ // Invoke both handlers when provided to allow parent onClose
+ // and consumer-provided closeButtonProps.onPress to run.
+ onClose?.();
closeButtonPropsOnPress?.(event);
}
: undefined;You can send follow-ups to the cloud agent here.
Reviewed by Cursor Bugbot for commit 5eb5853. Configure here.
5eb5853 to
66f31c3
Compare
📖 Storybook Preview |
Co-authored-by: Cursor <cursoragent@cursor.com>
## Release 39.0.0 This release adds Tailwind CSS v4 integration via `@metamask/design-tokens/tailwind/theme.css`, ships extension migration UI on React web (`Modal`, `ModalContent`, `Skeleton`, `HeaderBase`), adds Tailwind preset animations (`animate-slide-up`, `animate-skeleton-pulse`), and refreshes the shared icon set (`ListArrow`, `Musd`, `MusdFilled`, `Group`, `PieChart`, `Predictions`, refreshed `Candlestick`, `Musd` SVG fix) across `@metamask/design-system-shared`, React, and React Native. **React Native** also ships a **breaking** Toast follow-up ([#1143](#1143)): root **`Toaster`**, imperative **`toast`** / **`toast.dismiss()`**, and flat **`ToastSeverity`** options. The TWRNC preset widens its React peer range for newer React Native / React stacks. ### 📦 Package Versions - `@metamask/design-tokens`: **8.4.0** - `@metamask/design-system-shared`: **0.17.0** - `@metamask/design-system-react`: **0.22.0** - `@metamask/design-system-react-native`: **0.24.0** - `@metamask/design-system-tailwind-preset`: **0.8.0** - `@metamask/design-system-twrnc-preset`: **0.4.2** ### 🎨 Design Tokens (8.4.0) #### Added (#1117) **What changed** - Added `@metamask/design-tokens/tailwind/theme.css` for Tailwind CSS v4 so consumers can import MetaMask token variables, theme values, typography, font, and shadow utilities in one place. **Impact** - Web apps on Tailwind v4 can adopt the token theme without hand-rolling CSS variables; see [Tailwind CSS v3 to v4](./packages/design-tokens/MIGRATION.md#tailwind-css-v3-to-v4). ### 🪶 `@metamask/design-system-tailwind-preset` (0.8.0) #### Added - **`animate-slide-up`** (and `slide-up` keyframes) for the same dialog entrance motion as `ModalContent` ([#1139](#1139)) - **`animate-skeleton-pulse`** (and `skeleton-pulse` keyframes) for loading placeholders used with `Skeleton` ([#1146](#1146)) ### 📲 `@metamask/design-system-twrnc-preset` (0.4.2) #### Changed (#844) - Expanded the `react` peer dependency range to `>=18.2.0` so the preset installs cleanly alongside React Native 0.76 and React 19 app stacks. ### 🔄 Shared Type Updates (0.17.0) #### Shared icon set (#1157, #1161, #1162, #1163) **What changed** - Extended the shared icon set with `ListArrow`, `Musd`, `MusdFilled`, `Group`, `PieChart`, and `Predictions`, refreshed the `Candlestick` icon, and corrected the `Musd` asset to use a single SVG path. **Impact** - Keeps `IconName` and assets aligned for `@metamask/design-system-react` and `@metamask/design-system-react-native`. ### 🌐 React Web Updates (0.22.0) #### Added - Added `Modal` and `ModalContent` for dialogs, `Skeleton` for loading placeholders, and `HeaderBase` for header layouts—supporting the MetaMask extension migration into the design system ([#1136](#1136), [#1139](#1139), [#1146](#1146), [#1142](#1142)) - Added icons `ListArrow`, `Musd`, `MusdFilled`, `Group`, `PieChart`, and `Predictions`, and updated the `Candlestick` icon ([#1157](#1157), [#1161](#1161), [#1162](#1162)) #### Fixed - Corrected the `Musd` icon asset so it renders from a single SVG path ([#1163](#1163)) ### 📱 React Native Updates (0.24.0) #### Added - Added icons `ListArrow`, `Musd`, `MusdFilled`, `Group`, `PieChart`, and `Predictions`, and updated the `Candlestick` icon ([#1157](#1157), [#1161](#1161), [#1162](#1162)) #### Changed - **BREAKING:** Toast API follow-up ([#1143](#1143)): mount **`<Toaster />`** once at the root; use **`toast(...)`** / **`toast.dismiss()`** instead of **`Toast.show(...)`** / **`Toast.hide()`**; content-first options with **`ToastSeverity`** and **`iconAlertProps`** (renamed from **`iconProps`**). See [Migration Guide](./packages/design-system-react-native/MIGRATION.md#from-version-0230-to-0240). #### Fixed - Corrected the `Musd` icon asset so it renders from a single SVG path ([#1163](#1163)) ###⚠️ Breaking Changes #### React Native — Toast (#1143) **What changed** - Imperative API moves from **`Toast.show`** / **`Toast.hide`** on **0.23.x** to **`toast`** / **`toast.dismiss()`** with a root **`<Toaster />`**. - Options flatten to **`title`**, **`description`**, **`severity`** (**`ToastSeverity`**), accessories, and **`iconAlertProps`**; map **`ToastVariant`**-style payloads from **0.23.0** using the migration guide. **Migration** - See [From version 0.23.0 to 0.24.0](./packages/design-system-react-native/MIGRATION.md#from-version-0230-to-0240) (and [Toast Component](./packages/design-system-react-native/MIGRATION.md#toast-component) for component-library migration context). ### ✅ Checklist - [x] Changelogs updated with human-readable descriptions - [x] Changelog validation passed (`yarn changelog:validate`) - [x] Version bumps follow semantic versioning - [x] design-tokens: minor (8.3.0 → 8.4.0) — Tailwind v4 `theme.css` entry point - [x] design-system-shared: minor (0.16.0 → 0.17.0) — shared icon set additions and asset fixes - [x] design-system-react: minor (0.21.0 → 0.22.0) — extension migration components and icons - [x] design-system-react-native: minor (0.23.0 → 0.24.0) — **breaking Toast follow-up (#1143)**, icons, `Musd` fix - [x] design-system-tailwind-preset: minor (0.7.0 → 0.8.0) — `animate-slide-up` and `animate-skeleton-pulse` for ModalContent / Skeleton - [x] design-system-twrnc-preset: patch (0.4.1 → 0.4.2) — wider `react` peer range - [x] Breaking changes documented with migration guidance (React Native Toast — see MIGRATION.md link above) - [x] Migration guides updated with before/after examples (Toast **0.23 → 0.24**; Tailwind v4 consumers — design-tokens migration link above) - [x] PR references included in changelog entries ## **Pre-merge author checklist** - [x] I've followed [MetaMask Contributor Docs](https://github.com/MetaMask/contributor-docs) - [x] I've reviewed the [Release Workflow](./.cursor/rules/release-workflow.md) cursor rule - [x] All tests pass (`yarn build && yarn test && yarn lint`) - [x] Changelog validation passes (`yarn changelog:validate`) ## **Pre-merge reviewer checklist** - [ ] I've reviewed the [Reviewing Release PRs](./docs/reviewing-release-prs.md) guide - [ ] Package versions follow semantic versioning - [ ] Changelog entries are consumer-facing (not commit message regurgitation) - [ ] Breaking changes are documented in MIGRATION.md with examples (**React Native Toast** — [0.23.0 → 0.24.0](./packages/design-system-react-native/MIGRATION.md#from-version-0230-to-0240)) - [ ] All unreleased changes are accounted for in changelogs <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Medium Risk** > Primarily a release/version bump, but it changes published package versions and updates peer dependency requirements, which can affect downstream installs. React Native release notes include a breaking `Toast` API change that consumers must account for when upgrading. > > **Overview** > Bumps the monorepo release to `39.0.0` and increments package versions for `@metamask/design-system-react` (`0.22.0`), `@metamask/design-system-react-native` (`0.24.0`), `@metamask/design-system-shared` (`0.17.0`), and `@metamask/design-system-tailwind-preset` (`0.8.0`), updating corresponding changelogs and compare links. > > Updates `@metamask/design-system-react` to require `@metamask/design-system-tailwind-preset@^0.8.0` (and aligns `yarn.lock`). Changelogs capture the release contents, including new modal/skeleton/header additions on web, icon set updates across packages, and a **breaking** React Native `Toast` API tightening for `Toaster`/`toast(...)` usage. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 4e3ea63. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY -->


Description
Follow-up to #1104 (
feat: new Toast API design).This PR realigns the React Native Toast API with the shipped Figma component, current extension naming, and the intended consumer-facing runtime usage.
The main changes are:
<Toaster />for the mounted renderer,toast(...)for showing a toast, andtoast.dismiss()for dismissal<Toast />as the presentational surface for Storybook, Code Connect, and direct rendering when neededtitle,description,severity, optionalstartAccessory, andactionButtonLabel/actionButtonOnPressToastSeverity.Defaultas the no-icon default and align supported severities toDefault,Success,Warning, andDangerIconAlert, while keepingstartAccessoryas the override pathhasNoTimeouttofalse, and renameiconPropstoiconAlertPropsExample runtime usage after this PR:
Related issues
Fixes: https://consensyssoftware.atlassian.net/browse/DSYS-695
Related:
Manual testing steps
yarn build.yarn test.yarn lint.Default,Title,Description,Severity,StartAccessory, andActionButtonOnPress.Screenshots/Recordings
after720.mov
Pre-merge author checklist
Pre-merge reviewer checklist
Note
Medium Risk
Breaking API refactor for Toast/Toaster (new exports, renamed/removed methods and option shapes) plus moved animation/state logic into
Toaster, which can impact all consumers and toast dismissal behavior.Overview
Refactors the React Native toast system to a split model: a root-mounted
Toasterowns rendering/animation and registers the imperativetoast(...)+toast.dismiss()API, whileToastbecomes a presentational surface component intended for direct rendering (Storybook/docs).Aligns the public options/types with the shipped design by replacing variant-specific unions with flat content-first props (
title,description,actionButtonLabel/actionButtonOnPress,startAccessory) and introducingToastSeverity(Default|Success|Warning|Danger) withIconAlert-backed severity icons (andstartAccessoryas the override). Updates runtime semantics includinghasNoTimeoutdefaulting tofalse, renamingiconPropstoiconAlertProps, and adjusting close-button handling (closeButtonProps/onClose).Updates exports, Storybook stories, Figma Code Connect, tests (new
Toaster+toastcoverage, simplifiedToasttests), and migration/docs to reflect the new API and removals (Toast.show/hide,ToastVariant,ToastView, and legacy option wrappers).Reviewed by Cursor Bugbot for commit 66f31c3. Bugbot is set up for automated code reviews on this repo. Configure here.