Skip to content

fix(snack-bar): snack bar not animating in if no positions are passed in #11230

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

Merged
merged 1 commit into from
May 15, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions src/lib/snack-bar/snack-bar.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,31 @@ describe('MatSnackBar', () => {
.toContain('custom-class', 'Expected class applied through the defaults to be applied.');
}));

it('should position the snack bar correctly if no default position is defined', fakeAsync(() => {
overlayContainer.ngOnDestroy();
viewContainerFixture.destroy();

TestBed
.resetTestingModule()
.overrideProvider(MAT_SNACK_BAR_DEFAULT_OPTIONS, {
deps: [],
useFactory: () => ({politeness: 'polite'})
})
.configureTestingModule({imports: [MatSnackBarModule, NoopAnimationsModule]})
.compileComponents();

inject([MatSnackBar, OverlayContainer], (sb: MatSnackBar, oc: OverlayContainer) => {
snackBar = sb;
overlayContainer = oc;
overlayContainerElement = oc.getContainerElement();
})();

const snackBarRef = snackBar.open(simpleMessage);
flush();

expect(snackBarRef.containerInstance._animationState).toBe('visible-bottom');
}));

describe('with custom component', () => {
it('should open a custom component', () => {
const snackBarRef = snackBar.openFromComponent(BurritosNotification);
Expand Down
2 changes: 1 addition & 1 deletion src/lib/snack-bar/snack-bar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ export class MatSnackBar {
private _attach<T>(content: ComponentType<T> | TemplateRef<T>, userConfig?: MatSnackBarConfig):
MatSnackBarRef<T | EmbeddedViewRef<any>> {

const config = {...this._defaultConfig, ...userConfig};
const config = {...new MatSnackBarConfig(), ...this._defaultConfig, ...userConfig};
const overlayRef = this._createOverlay(config);
const container = this._attachSnackBarContainer(overlayRef, config);
const snackBarRef = new MatSnackBarRef<T | EmbeddedViewRef<any>>(container, overlayRef);
Expand Down