Repository navigation
fix(toast): keep error and action toasts until the user closes them #687
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
ddc120a
fix(toast): keep error and action toasts until the user closes them
228389d
fix(toast): reset sticky defaults when a toast is updated by id
73258ee
Merge branch 'main' into fix/toast-defaults
wemra3 8df6d72
Merge branch 'main' into fix/toast-defaults
wemra3 e8b3ba7
Merge branch 'main' into fix/toast-defaults
wemra3 729f520
fix(toast): leave non-dismissible toasts on Sonner's defaults
8c486c4
feat(toast): add toastDefaults to AppShell
d29f5a4
Merge remote-tracking branch 'origin/main' into wip/toast-dismissible
1f2a06e
refactor(toast): hoist applyDefault to module scope
f316a24
Merge branch 'main' into fix/toast-defaults
wemra3 a4b8382
Merge branch 'main' into fix/toast-defaults
wemra3 ae7c2fb
Merge remote-tracking branch 'origin/main' into fix/toast-defaults
2cbc099
feat(toast): override toastDefaults field by field and reject empty k…
88db3af
Merge branch 'fix/toast-defaults' of https://github.com/tailor-platfo…
62eb652
style(toast): drop formatting-only changes from the previous commit
2c48058
Merge branch 'main' of https://github.com/tailor-platform/app-shell i…
894bc9b
fix(toast): keep toastDefaults stable when it is written inline
f4df188
fix(toast): keep the success state of toast.promise with an action
a50d480
Merge commit '923933d' into fix/toast-defaults
ae4a42f
Merge branch 'main' into fix/toast-defaults
wemra3 56c3cb3
docs(toast): give repeatable errors a stable id
interacsean b57764c
Merge branch 'main' into fix/toast-defaults
wemra3 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| --- | ||
| "@tailor-platform/app-shell": minor | ||
| --- | ||
|
|
||
| Error toasts, and toasts with an `action`, now stay until the user closes them. `useToast` gives `toast.error(...)`, the error state of `toast.promise(...)`, and any call with an `action` the defaults `duration: Infinity` and `closeButton: true`. Before, Sonner closed every toast after 4 seconds, so a failed save could disappear before the user read it, and an Undo could vanish while the user reached for it. | ||
|
|
||
| This changes what users see after the update. To keep the previous behavior, or to set your own defaults, use the new `toastDefaults` prop of `AppShell`. A field set there replaces that field only; fields and kinds left out keep the new default. An empty object such as `error: {}` is a type error. See the migration guide (`docs/migrations.md`, 1.21.0). | ||
|
|
||
| ```tsx | ||
| // The previous behavior (4 seconds, no close button) for both kinds | ||
| <AppShell | ||
| toastDefaults={{ | ||
| error: { duration: 4000, closeButton: false }, | ||
| action: { duration: 4000, closeButton: false }, | ||
| }} | ||
| modules={modules} | ||
| /> | ||
| ``` | ||
|
|
||
| A `duration` or `closeButton` passed to the call still wins: | ||
|
|
||
| ```ts | ||
| toast.error("Retrying in 5s", { duration: 5000 }); // closes after 5 seconds | ||
| ``` | ||
|
|
||
| A call without an `action` that updates one of these toasts by `id` resets `duration` and `closeButton` to Sonner's defaults unless it passes its own. `toast.custom`, toasts with `dismissible: false`, and success, info, warning and plain toasts without an `action` keep Sonner's defaults. The position (bottom right), the number of visible toasts (3) and the z-index are unchanged. A `toast` imported from `sonner` directly does not get the new defaults. | ||
|
|
||
| The toast docs (`patterns/interaction-toast`, `api/use-toast`) now describe the real position, count and durations. They used to say top right, one at a time, and 3 seconds for success. | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.