components icon indicating copy to clipboard operation
components copied to clipboard

Snackbar notification leaves message on page

Open largeDachshund opened this issue 9 years ago • 11 comments

Bug:

When I invoke Snackbar, the message appears both in a floating box and as text, just above the snackbar. image

After the snackbar disappears, the text remains on the page.

What is the expected behavior?

When the snackbar is invoked, the text that appears on the page should not be shown.

Which versions of Angular, Material, OS, browsers are affected?

"angular-cli": "^1.0.0-beta.24" "hammerjs": "^2.0.8", "@angular/core": "^2.3.1", "@angular/forms": "^2.3.1" "@angular/material": "^2.0.0-beta.1"

Chrome

Is there anything else we should know?

I created a service: `@Injectable() export class NotificationService { private _snackBarConfig: MdSnackBarConfig;

constructor(public snackBar: MdSnackBar) {
    this._snackBarConfig = new MdSnackBarConfig();

    this._snackBarConfig.duration = 10000;
}

public callSnackBar(message: string) {
    this.snackBar.open(message, null, this._snackBarConfig);
}`

Then, when I call it: `this._msgNotification = "The system did not return any " + "tenants. You're session may have expired. Please login, again.";

                    this._notifService.callSnackBar(this._msgNotification);`

largeDachshund avatar Jan 04 '17 18:01 largeDachshund

One of those texts is supposed to be hidden and used to announce the snack bar to screen readers. Are you sure that you followed the theming guide and included all of the necessary CSS?

crisbeto avatar Jan 04 '17 20:01 crisbeto

@crisbeto , I haven't had a chance to implement a theme. Is it really required, then?

largeDachshund avatar Jan 04 '17 20:01 largeDachshund

It is, because it provides some of the core styles, e.g. the backdrops will be transparent if you don't provide one. There are some pre-built ones that are distributed with the Material releases.

crisbeto avatar Jan 04 '17 20:01 crisbeto

@crisbeto , so, taking the example, how do i reference the theme in the template? is it as simple as (app.component.html):

<div class="candy-apple-theme">
angular stuff here
</div>

largeDachshund avatar Jan 04 '17 20:01 largeDachshund

You don't need to reference, you just include it as a regular CSS file somewhere in your HTML.

crisbeto avatar Jan 04 '17 21:01 crisbeto

i'm using angular-cli. according to the example, you save it as a SASS file....don't do this?

largeDachshund avatar Jan 04 '17 21:01 largeDachshund

Via the theming guide:

If you're using Angular CLI, this is as simple as including one line in your style.css file:

@import '~@angular/material/core/theming/prebuilt/deeppurple-amber.css';

crisbeto avatar Jan 04 '17 21:01 crisbeto

@crisbeto , thanks for the help. I'm implementing the theme, now. and i'm still seeing that text left by the snackbar notification!

largeDachshund avatar Jan 04 '17 21:01 largeDachshund

Cool, glad to help. I'll consider this one resolved.

crisbeto avatar Jan 04 '17 21:01 crisbeto

yes. consider it resolved. there should be some explanation on Snackbar that theming is required.

largeDachshund avatar Jan 04 '17 23:01 largeDachshund

This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.