-
Notifications
You must be signed in to change notification settings - Fork 3.4k
fix(toast): toast defaults to wrong values when passed an empty position #11843
fix(toast): toast defaults to wrong values when passed an empty position #11843
Conversation
From https://material.angularjs.org/latest/api/service/$mdToast#mdtoast-show-optionsorpreset:
I managed to fix the example by not passing |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we try to have the function that handles the position
input use the proper, documented defaults when an empty string or any other invalid value is passed in?
Good point. I will submit an updated version next week. |
Sounds good. |
If no position was provided for whatever reason, the default behavior should be to open from the bottom.
@Splaktar Sorry for the delay. It should be better now. |
- position of "" uses document default positioning - "bottom left" - position of "left" or "right" uses default vertical positioning: "bottom" - improve JSDoc Closes #11843
- position of "" uses documented default positioning - "bottom left" - position of "left" or "right" uses default vertical positioning: "bottom" - improve JSDoc Closes #11843
I tested this updated fix and it doesn't appear to work. After some investigation, I discovered that there was actually a different place in the code that needed to change. I've opened PR #11904 to solve this. |
- position of "" uses documented default positioning - "bottom left" - position of "left" or "right" uses default vertical positioning: "bottom" - improve JSDoc Closes #11843. BREAKING CHANGE: $mdToast.show()'s position behavior has been updated to be consistent with the documentation. If you relied on the previously undocumented behavior where it defaulted to `top left` instead of `bottom left`, you will need to update your app. Change your code from this: ```js $mdToast.show( $mdToast.simple() .textContent('Simple Toast!')) .then(... ``` To this: ```js $mdToast.show( $mdToast.simple() .textContent('Simple Toast!') .position('top left')) .then(... ```
- position of "" uses documented default positioning - "bottom left" - position of "left" or "right" uses default vertical positioning: "bottom" - improve JSDoc Closes #11843. BREAKING CHANGE: `$mdToast.show()`'s position behavior has been updated to be consistent with the documentation. If you relied on the previously undocumented behavior where it defaulted to `top left` instead of `bottom left`, you will need to update your app. Change your code from this: ```js $mdToast.show( $mdToast.simple() .textContent('Simple Toast!')) .then(... ``` To this: ```js $mdToast.show( $mdToast.simple() .textContent('Simple Toast!') .position('top left')) .then(... ```
- position of "" uses documented default positioning - "bottom left" - position of "left" or "right" uses default vertical positioning: "bottom" - improve JSDoc Closes #11843. BREAKING CHANGE: `$mdToast.show()`'s position behavior has been updated to be consistent with the documentation. If you relied on the previously undocumented behavior where it defaulted to `top left` instead of `bottom left`, you will need to update your app. Change your code from this: ```js $mdToast.show( $mdToast.simple() .textContent('Simple Toast!')) .then(... ``` To this: ```js $mdToast.show( $mdToast.simple() .textContent('Simple Toast!') .position('top left')) .then(... ```
If the user specifies no position at all, the toast will open from the top, while the class name will reflect a toast opening from the bottom.
By chaning the ternary as suggested, we end up with the correct default case while maintaining all configured cases as-is.
PR Checklist
Please check that your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
What is the current behavior?
Go to https://material.angularjs.org/latest/demo/toast and uncheck all 4 checkboxes, then trigger a toast. The toast will appear on the top, the bottom FAB will make space for the toast.
What is the new behavior?
The toast will appear on the top, the top FAB will make space for the toast.
Does this PR introduce a breaking change?