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

Dismissable setting doesn't work both ways #14

Closed
1 of 2 tasks
charlieandroid55 opened this issue Apr 13, 2024 · 4 comments · Fixed by #17
Closed
1 of 2 tasks

Dismissable setting doesn't work both ways #14

charlieandroid55 opened this issue Apr 13, 2024 · 4 comments · Fixed by #17
Labels
bug Something isn't working released

Comments

@charlieandroid55
Copy link

Please provide the environment you discovered this bug in.

<ngx-sonner-toaster closeButton="false"/>
 toast.error('Error toast', {dismissable: true});

Description

The dismissable configuration, which is managed at the instance level, in my opinion, should override the global closeButton configuration in both directions. If I set closeButton to true, I expect most of my toasts to have that action, except for a few that cannot be closed. However, if I set closeButton to false, I mean that none of them should be closable by default, except for the one that has dismissable set to true. This way, I would have control over when and how a toast can be dismissed.

Currently, the behavior works as expected in version 0.4.1 for the following configuration: closeButton=true | dismissable=false.

However, the following configuration needs to be implemented: closeButton=false | dismissable=true.

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
@charlieandroid55 charlieandroid55 added the bug Something isn't working label Apr 13, 2024
@tutkli
Copy link
Owner

tutkli commented Apr 16, 2024

Hi, @charlieandroid55 ! The dismissible property of the toast refer to the ability to swipe out a toast, which is currently not working (Fixing it in #16 ).

For this, I'll add a closeButton property to the toastOptions, so you can override the toaster config.

  1. Toast don't have a close button by default, except when instatiating then with closeButton: true:
<ngx-sonner-toaster closeButton="false"/>
toast('Some message', {closeButton: true});
  1. Toasts have a closeButton by default, but can be hidden when instatiating with closeButton: false
<ngx-sonner-toaster closeButton />
toast('Some message', {closeButton: false});

Also, I'll be adding some docs to the types so everything is clearer.

@charlieandroid55
Copy link
Author

Hi @tutkli, ok, it works for me, but I think you should keep the API simpler. Maybe another global property can be applied to indicate that toasts can be swipeable and marking the toast instance with dismissable:false blocks the gesture and hides the close button preventing to the user to close this instance, what I suggest is that we need a way to cancel any action that allows closing a toast instance, otherwise now to achieve this we must take into account two options.

@tutkli
Copy link
Owner

tutkli commented Apr 16, 2024

I understand, but I think it's okay to have the two options as they are two diferent actions. Adds more customization.
The original API is also like this, and I did not included it in first time.

Bear with me as this is the first angular port I make , but I'm trying to make it as best as possible 😅

@tutkli
Copy link
Owner

tutkli commented Apr 16, 2024

🎉 This issue has been resolved in version 1.0.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working released
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants