-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
feat(Notification): add onClose support #7918
feat(Notification): add onClose support #7918
Conversation
Deploy preview for carbon-elements ready! Built with commit 741f30e |
Deploy preview for carbon-components-react ready! Built without sensitive environment variables with commit 741f30e https://deploy-preview-7918--carbon-components-react.netlify.app |
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 👍 ✅
@@ -266,25 +267,33 @@ export function ToastNotification({ | |||
[`${prefix}--toast-notification--${kind}`]: kind, | |||
}); | |||
|
|||
const handleClose = useCallback( | |||
(evt) => { | |||
if (!onClose || onClose(evt) !== false) { |
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.
For the onClose(evt) !== false
branch, would we more so want people to be able to configure visibility of the close button if they aren't able to dismiss/close the notification?
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.
this is for the visibility of the notification itself, similar to how the visibility of modals is controlled rather than the visibility of the modal close button
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.
@emyarod right, the way I interpreted it was that if the onClose
prop is called and returns false
then it will prevent the close from happening. Is that correct?
If so, then I was just asking that if the notification is unable to be dismissed (the onClose
prop would return false
) it seems like there would need to be some indicator of that. I think from my comment that was hiding the button if someone couldn't dismiss the notification but it could be something else, for sure.
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.
wouldn't this be left up to the consumer to resolve? similar to how we provide this API in our modals
4109320
to
e3d676d
Compare
Hi. I've just upgraded to Edit... I might have misread the state of affaires… I thought it's already merged, but now I see that it's just approved… the question holds though :-) |
@emyarod is this good to go? |
Closes #7859
This PR adds support for the
onClose
method on ToastNotification and InlineNotification. Similar to the ComposedModal the default close behavior can be avoided if the method returnsfalse
Changelog
New
onClose
support in ToastNotification and InlineNotificationTesting / Reviewing
Confirm that the
onClose
action appears in the storybook action logger. When editing the return value of the method locally, returningfalse
should prevent the notification from closing