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

MDCSnackbarFoundation has a hide event, but no onDismissed callback #2916

Closed
veonua opened this issue Jun 9, 2018 · 4 comments · Fixed by #4166
Closed

MDCSnackbarFoundation has a hide event, but no onDismissed callback #2916

veonua opened this issue Jun 9, 2018 · 4 comments · Fixed by #4166
Labels

Comments

@veonua
Copy link

veonua commented Jun 9, 2018

There is no user-defined callback to handle snackbar dismiss.

For comparison, Android has Snackbar.Callback.

What MDC Web Version are you using?

0.34.0

What are the steps to reproduce the bug?

in docs

const dataObj = {
  message: messageInput.value,
  actionText: 'Undo',
  actionHandler: function() {
    console.log('my cool function');
  }
};

What is the expected behavior?

const dataObj = {
  // ...
  dismissHandler: function(reason:int) {
    if (reason == DISMISS_EVENT_CONSECUTIVE) {
       console.log('dismissed');
    }
  } 
};

What is the actual behavior?

Right now it is not possible to respond to snackbar dismissing.

@kfranqueiro
Copy link
Contributor

Are you looking for the MDCSnackbar:hide event?

Though you raise an interesting point in that we might want to examine exposing the action handler consistently to the show and hide events.

@veonua
Copy link
Author

veonua commented Jun 11, 2018 via email

@kfranqueiro
Copy link
Contributor

I'm going to track this so we can investigate the current balance of APIs.

I can see where action and dismiss could be considered complements to each other, but I'm also unsure why snackbar was originally implemented with show/hide as DOM events on the snackbar element, while actionHandler is a passed-in callback; this seems inconsistent - i.e., why aren't they all callbacks? Or why couldn't we simply emit a MDCSnackbar:action event, too? I'd ideally like to expose an API that is consistent, but still satisfies use cases easily.

It would be helpful to know specifically what your usage flow looks like with snackbar - e.g. how are you reusing snackbar instances, and how diverse are the action / dismiss handlers?

@kfranqueiro kfranqueiro changed the title MDCSnackbarFoundation has no onDismissed callback MDCSnackbarFoundation has a hide event, but no onDismissed callback Jun 18, 2018
@veonua
Copy link
Author

veonua commented Jun 18, 2018 via email

acdvorak added a commit that referenced this issue Dec 13, 2018
### Issues fixed

* Fixes #4005 (via new `mdc-snackbar-viewport-margin()` mixin)
* Fixes #3981
* Fixes #2916 (via new `MDCSnackbar:closing` and `MDCSnackbar:closed` events)
* Fixes #2628
* Fixes #1466 (via new `close()` method)
* Fixes #1398
* Fixes #1258
* Fixes #11 (the label now expands indefinitely to fit the text)
* Refs #2813

### Screenshots

![Baseline without action button](https://user-images.githubusercontent.com/409245/49956261-a080ca80-feb9-11e8-8287-b7e805344115.png)

![Baseline with action button](https://user-images.githubusercontent.com/409245/49956109-4a138c00-feb9-11e8-9213-3241fa86a1b8.png)

![Stacked layout](https://user-images.githubusercontent.com/409245/49956173-6a434b00-feb9-11e8-8a03-2e58ccc8f763.png)

BREAKING CHANGE: Snackbar's DOM and APIs have changed to match the latest design guidelines. See the Snackbar documentation for more information.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants