Skip to content

DEV: standardise toasts duration #32741

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 4 commits into from
May 15, 2025
Merged

Conversation

jjaffeux
Copy link
Contributor

Toasts can now have two durations:

  • short -> 3000ms
  • long -> 5000ms

Anything else will be converted to 3000ms

Toasts can now have two durations:
- `short` -> 3000ms
- `long` -> 5000ms

Anything else will be converted to 3000ms
@github-actions github-actions bot added the chat PRs which include a change to Chat plugin label May 15, 2025
Comment on lines 64 to 72
get duration() {
let duration = this.args.toast.options.duration;

if (duration === "long") {
return 5000;
} else {
return 3000;
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Some plugins use toasts, so maybe we need a backwards compatible code path with a deprecation warning?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I hesitated, but I think in this case, it's not breaking the application, it's mostly a UX detail. Maybe I could get convinced that 5000 is a better default?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You know what? OK let's show a deprecation message, I don't really mind and we can just remove it in 6 months.

Copy link
Contributor

Choose a reason for hiding this comment

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

Good catch, maybe if duration is an integer we can show the deprecation warning and allow returning the value for the short term. Probably not a big deal though, I can't imagine there are many cases where anyone wants a toast for more than 3-5 seconds.

Copy link
Contributor

@dbattersby dbattersby left a comment

Choose a reason for hiding this comment

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

Looks good, I don't have strong preference but can add a deprecation notice or allow for integer values too if you decide.

@jjaffeux jjaffeux merged commit 2e4076f into discourse:main May 15, 2025
16 checks passed
@jjaffeux jjaffeux deleted the short-long-toast branch May 15, 2025 12:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
chat PRs which include a change to Chat plugin
Development

Successfully merging this pull request may close these issues.

3 participants