-
Notifications
You must be signed in to change notification settings - Fork 991
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
Fixes #37915 - Give Toasts keys for ToastsList #10350
Conversation
Have you found out when and how that happens? |
Because we dont get them from rails. def toast_notifications_data
selected_toast_notifications = flash.select { |key, _| key != 'inline' }
selected_toast_notifications.map do |type, notification|
notification.is_a?(Hash) ? notification : { :type => type, :message => notification }
end
end The key is used for React to differentiate between tags in an rendered list, which is why we had "key={key}", but accidentally override it. |
I'm still trying to get my bearings so please bear with me. In case Also could you please point me to the place where |
Thanks for sending me to investigate this, I changed the pr to instead not send an undefined value in the railsMessages, since it will always be undefined and will override the random generated key given in: const key = toast.key || nanoid();
return { payload: { key, toast } }; |
That wasn't my intention, I'm just slowly trying to wrap my head around all the frontend bits we have, but thank you for diving into it.
Ah, so that's where it comes from |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Thank you @MariaAga ! |
toastProps key was sometimes empty, so it was overriding the key, I moved the key prop to be after the spread so it wont get overriden but will take the toastProp key if its not empty.
This was causing this error:
react.development.js:315 Warning: Each child in a list should have a unique "key" prop.
Check the render method of
ToastsList
in Alert (created by ToastsList)