Skip to content
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

useToast: Support dynamic dismiss timeout duration #1637

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

felixhabib
Copy link
Contributor

@felixhabib felixhabib commented Oct 22, 2024

Previously, all toasts would automatically dismiss after 10 seconds.
This update adjusts the timeout duration for toasts based on their content length, ensuring users have enough time to read the message, while minimising the time content is obscured by the toast.

Think actionable toasts should get a longer timeout

Timeout length is based off this calculation referenced here.

A good length of time to keep messages up is 5 seconds plus 1 extra second for every 120 words, rounding up. This is how fast the average American reads. That means the shortest default that should be used as a best practice is 6 seconds.

@felixhabib felixhabib requested a review from a team as a code owner October 22, 2024 22:36
Copy link

changeset-bot bot commented Oct 22, 2024

🦋 Changeset detected

Latest commit: 0621d6f

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
braid-design-system Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@@ -15,6 +15,7 @@ export const useTimeout = ({ onTimeout, duration }: UseTimeoutProps) => {

useEffect(() => {
if (activated) {
setActivated(true);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One method of having the toast work on the docs site in local dev. Was hitting an issue with strict mode

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant