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

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

Merged
merged 1 commit into from
May 15, 2018

Conversation

crisbeto
Copy link
Member

@crisbeto crisbeto commented May 8, 2018

Adds some better handling for the case where no positions are passed into a snack bar. Currently the snack bar attempts to animate in to an invalid animation state.

Fixes #11197.

@googlebot googlebot added the cla: yes PR author has agreed to Google's Contributor License Agreement label May 8, 2018
@josephperrott
Copy link
Member

I think a better way to tackle this would be to set ensure the defaults are set in the open method in snack-bar.ts

We can do:

open(message: string, action: string = '', config?: MatSnackBarConfig):
    MatSnackBarRef<SimpleSnackBar> {
  const _config = {...new MatSnackBarConfig(), ...this._defaultConfig, ...config};

  // Since the user doesn't have access to the component, we can
  // override the data to pass in our own message and action.
  _config.data = {message, action};
  _config.announcementMessage = message;

  return this.openFromComponent(SimpleSnackBar, _config);
}

This will have our object as the default, while being overridden by whatever the user provides either by provider or at the time open is called.

@crisbeto
Copy link
Member Author

crisbeto commented May 9, 2018

That's what I was thinking initially. My reasoning for doing it this way is that the purpose of using the injection token in the first place is to be able to change the default values, but by creating a new MatSnackBarConfig, you're already setting some defaults that come with the class. That being said, we can go with the simpler solution and see if people end up being confused about it.

Adds some better handling for the case where no positions are passed into a snack bar. Currently the snack bar attempts to animate in to an invalid animation state.

Fixes angular#11197.
@crisbeto crisbeto force-pushed the 11197/snack-bar-defaults branch from 66ba197 to 42b1d7c Compare May 9, 2018 05:55
@jelbourn
Copy link
Member

jelbourn commented May 9, 2018

I see specifying the default options as overriding the defaults for the ones you provide; anything left unspecified would just be the original default.

@crisbeto
Copy link
Member Author

crisbeto commented May 9, 2018

The feedback has been addressed.

Copy link
Member

@josephperrott josephperrott left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@josephperrott josephperrott added pr: lgtm action: merge The PR is ready for merge by the caretaker target: patch This PR is targeted for the next patch release and removed pr: needs review labels May 14, 2018
@ngbot
Copy link

ngbot bot commented May 14, 2018

I see that you just added the pr: merge ready label, but the following checks are still failing:
    failure status "continuous-integration/travis-ci/pr" is failing

If you want your PR to be merged, it has to pass all the CI checks.

If you can't get the PR to a green state due to flakes or broken master, please try rebasing to master and/or restarting the CI job. If that fails and you believe that the issue is not due to your change, please contact the caretaker and ask for help.

@tinayuangao tinayuangao merged commit f5377dd into angular:master May 15, 2018
tinayuangao pushed a commit that referenced this pull request May 15, 2018
… in (#11230)

Adds some better handling for the case where no positions are passed into a snack bar. Currently the snack bar attempts to animate in to an invalid animation state.

Fixes #11197.
crisbeto added a commit to crisbeto/material2 that referenced this pull request May 15, 2018
… in (angular#11230)

Adds some better handling for the case where no positions are passed into a snack bar. Currently the snack bar attempts to animate in to an invalid animation state.

Fixes angular#11197.
crisbeto added a commit to crisbeto/material2 that referenced this pull request May 15, 2018
… in (angular#11230)

Adds some better handling for the case where no positions are passed into a snack bar. Currently the snack bar attempts to animate in to an invalid animation state.

Fixes angular#11197.
@angular-automatic-lock-bot
Copy link

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.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 8, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
action: merge The PR is ready for merge by the caretaker cla: yes PR author has agreed to Google's Contributor License Agreement target: patch This PR is targeted for the next patch release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Using MAT_SNACK_BAR_DEFAULT_OPTIONS in parent module don't show snackbar at all
5 participants