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

Unable to Prevent Toast Close Using event.preventDefault() in Action Button Callback #34

Open
1 of 2 tasks
RaimonxDev opened this issue Dec 28, 2024 · 0 comments
Open
1 of 2 tasks
Labels
bug Something isn't working

Comments

@RaimonxDev
Copy link

Please provide the environment you discovered this bug in.

ngx-sonner: 2.0.2
angular: 18.2.11
angular-cdk: 18.2.11

Description

Hello, I am on version 2.0.2, and while reading the documentation about action buttons, it says:

You can prevent the toast from closing by calling event.preventDefault() in the onClick callback.

I am trying to replicate this, but the sonner still closes, not work. Am I doing something wrong? I thought the event came from onClick, but it doesn’t have any parameters.

toast('Invalid form', {
description: 'Please check the fields marked in red',
cancel: {
label: 'Ok',
onClick: () => {
event?.preventDefault();
},
},
position: 'top-right',
duration: 4000,
});

Thanks for this amazing library!

Please provide the exception or error you saw

No response

Other information

No response

I would be willing to submit a PR to fix this issue

  • Yes
  • No
@RaimonxDev RaimonxDev added the bug Something isn't working label Dec 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant