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

fix: aria prop issue #393

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

daangnkim
Copy link

@daangnkim daangnkim commented Jan 30, 2025

Summary

"toast" method's toast messages, using the "error" or "success" properties, do not apply the configured "ariaProps" options in the Toaster component. Please refer to the following link for more details.

#244

Reason

When the "error" or "success" properties of the toast function are called, the createToast function is invoked. However, the issue lies in the fact that createToast defines default values for ariaProps.

const createToast = (
  message: Message,
  type: ToastType = 'blank',
  opts?: ToastOptions
): Toast => ({
  createdAt: Date.now(),
  visible: true,
  type,
  ariaProps: {
    role: 'status',
    'aria-live': 'polite',
  },
  message,
  pauseDuration: 0,
  ...opts,
  id: opts?.id || genId(),
});

This value is causing an issue by overriding the globally set ariaProps option

Solution

Firstly, I made ariaProps an optional property for the Toast type. (1e46473)

Secondly, within the createToast, I removed the ariaProps that were initially defined. (21d4326)

Lastly, within the store, I created a variable named 'defaultAriaProps' to ensure default values are applied to ariaProps. (0beaee3)

Copy link

vercel bot commented Jan 30, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
react-hot-toast ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 30, 2025 6:25am

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