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

Ability to hook into Snackbar messaging #200

Closed
mattcorner opened this issue Jun 12, 2020 · 7 comments · Fixed by #205
Closed

Ability to hook into Snackbar messaging #200

mattcorner opened this issue Jun 12, 2020 · 7 comments · Fixed by #205
Milestone

Comments

@mattcorner
Copy link

Feature Request

Describe the problem related to this feature request

I'm beginning to wonder if it would be better for me to able to hook in directly to the snackbar messages, and use my own components rather than relying on the the included snackbar.

Some issues that this would solve:

  • Snackbars drawing over each other.
  • Full control over what types, or even messages to show.
  • Full control over styling that theme override may not be able to provide.

Describe the solution you'd like

Expose a new prop. Something along the lines of
<Dropzone onMessage ={ (message, variant) => {//Do what I want}} />
Could be called in a useEffect with message and variant dependencies.

Describe alternatives you've considered

The alternative is to stick with the current system, but this will always be restrictive when the user wants full control. This proposal gives advanced users the information needed, without having to overly complicate the snackbar offering.

@max-carroll
Copy link
Contributor

max-carroll commented Jun 12, 2020 via email

@panz3r panz3r added this to the 4.x milestone Jun 12, 2020
@panz3r
Copy link
Contributor

panz3r commented Jun 12, 2020

Hi @mattcorner,

Thanks for your feedback, I came to the same conclusion some time ago (in one of my projects I disabled the integrated Snackbar to use Notistack instead).

I suppose we can add the ‘onMessage’ handler side-by-side with the current behavior so a user can react to the message events and, if he needs to, turn off the integrated Snackbar (by setting the showAlert prop).

This way we can avoid a major breaking change and quickly implement this new behavior you are suggesting.

@panz3r panz3r modified the milestones: 4.x, 3.3 Jun 12, 2020
@mattcorner
Copy link
Author

I was thinking about having a sendInfoMessage, sendErrorMessage,
send...Message functions exposed from a hook,

I don't really mind but from an api point of view it seems nice to to only expose one prop for this. I've implemented Context/Provider/Hook for snackbars in several projects and found one show (and hide) method on the hook to work well.

I suppose we can add the ‘onMessage’ handler side-by-side with the current behavior so a user can react to the message events and, if he needs to, turn off the integrated Snackbar (by setting the showAlert prop).

I had a quick flick through the code before raising, and it seems the messages are set in state regardless of whether snackbar is enabled so shouldn't be much hassle like you say. Just need to agree on an api that isn't going to change in 4.0 with the siwtch to hooks.

@mattcorner
Copy link
Author

p.s. Happy to support with any code/ pull request reviews on this if helpful.

@panz3r
Copy link
Contributor

panz3r commented Jun 14, 2020

I don't really mind but from an api point of view it seems nice to to only expose one prop for this. I've implemented Context/Provider/Hook for snackbars in several projects and found one show (and hide) method on the hook to work well.

I totally agree on this 👍

I suppose we can add the ‘onMessage’ handler side-by-side with the current behavior so a user can react to the message events and, if he needs to, turn off the integrated Snackbar (by setting the showAlert prop).

I had a quick flick through the code before raising, and it seems the messages are set in state regardless of whether snackbar is enabled so shouldn't be much hassle like you say. Just need to agree on an api that isn't going to change in 4.0 with the siwtch to hooks.

To keep it in line with the current “module dictionary” I’d say that the new method should be called onAlert (since we refer to the Snackbar using that name).

@mattcorner
Copy link
Author

onAlert

Sounds good to me. So we're looking at something like this in terms of doc:

PropName: onAlert
Type: func
Default: undefined
Description: Arguments

  • message: String - Alert message describing event that has occurred.
  • variant: Enum["info", "error", "success"] - Type of alert that has occurred.

In terms of functionality:

  • Should be available regardless of the showAlerts property value.

@panz3r
Copy link
Contributor

panz3r commented Jun 15, 2020

Hi @mattcorner ,

That looks great, would you like to try implementing it?

@mattcorner mattcorner mentioned this issue Jun 16, 2020
9 tasks
@panz3r panz3r linked a pull request Jun 17, 2020 that will close this issue
9 tasks
@panz3r panz3r closed this as completed Jun 17, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants