question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Avoid Snackbar to be hidden on external click

See original GitHub issue

Description

There is no way to prevent a Snackbar from being hidden when clicking outside. Or maybe I miss something. onRequestClose tells:

The reason parameter can optionally be used to control the response to onRequestClose, for example ignoring clickaway.

There is no doc regarding how to ignore such a clickaway. Is there?

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:4
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

19reactions
oliviertassinaricommented, Dec 28, 2019

The correct solution is to ignore the onClose event callback when reason === "clickaway" (since v1).

2reactions
TimAstiercommented, Dec 28, 2019

I couldn’t get this working with onRequestClose.
Instead I used ClickAwayListenerProps as so:

<MuiSnackbar
  // ...
  ClickAwayListenerProps={{ onClickAway: () => null }}
 >

Here are the docs for ClickAwayListnerProps for reference.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Avoid Snackbar to be hidden on external click #5184 - GitHub
The correct solution is to ignore the onClose event callback when reason === "clickaway" (since v1).
Read more >
Prevent Snackbar from dismissing on action click
First, set your snackbar action using an empty OnClickListener: snackbar.setAction("Save", new View.OnClickListener() { @Override ...
Read more >
Snackbars - Material Design
Don'tAvoid significantly altering the shape of a snackbar container. Snackbar without shadow. Don'tAvoid displaying a snackbar container without elevation.
Read more >
Build and display a pop-up message | Android Developers
A Snackbar is attached to a view. The Snackbar provides basic functionality if it is attached to any object derived from the View...
Read more >
Flutter: Showing SnackBar within the Widget that builds a ...
In this solution, you would have an outer widget that creates the Scaffold populated by instances of your new inner widgets, and then...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found