Why MDL Toast need mdl-snackbar__action button?

894 Views Asked by At

Some time ago in Apache Flex project we have started to port MDL library into FlexJS framework. [1]

When I was working on Toast component I have faced an issue where removing "mdl-snackbar__action" button from HTML cause an error. It seems that snackbar.js [2] throws an error if snackbar action doesn't exists.

 if (!this.actionElement_) {
      throw new Error('There must be an action element for a snackbar.');
    }

My question is - Why this element is required in case of Toast ? Toast component do not need it.

[1] https://cwiki.apache.org/confluence/display/FLEX/Table+Of+Components

[2] https://github.com/google/material-design-lite/blob/release/src/snackbar/snackbar.js

Thanks, Piotr

1

There are 1 best solutions below

0
On

I think it's because the snackbar and toast are implemented as a single component in the HTML/CSS. That way, an app can throw either type by either including or omitting the action-related parts of the data object that gets passed to the showSnackbar method.

It's just to cut down on the number of components in the library by making the one more flexible.