Skip to content
This repository was archived by the owner on Sep 5, 2024. It is now read-only.

Commit 617ab2c

Browse files
EladBezalelThomasBurleson
authored andcommitted
fix(toast): added position relative to toast parent
Toast is aligned by `position: absolute` therefore its parent must have `position: relative` to enable the toast align properly, * Added `position: relative` to the parent only if there's no computed style for position (checking for `static` because this is the default computed position) fixes #4542. closes #5660.
1 parent a7fc111 commit 617ab2c

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/components/toast/toast.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,12 @@ function MdToastProvider($$interimElementProvider) {
265265

266266
// 'top left' -> 'md-top md-left'
267267
options.parent.addClass(options.openClass);
268+
269+
// static is the default position
270+
if ($mdUtil.hasComputedStyle(options.parent, 'position', 'static')) {
271+
options.parent.css('position', 'relative');
272+
}
273+
268274
element.on(SWIPE_EVENTS, options.onSwipe);
269275
element.addClass(options.position.split(' ').map(function(pos) {
270276
return 'md-' + pos;
@@ -277,7 +283,12 @@ function MdToastProvider($$interimElementProvider) {
277283
element.off(SWIPE_EVENTS, options.onSwipe);
278284
if (options.openClass) options.parent.removeClass(options.openClass);
279285

280-
return (options.$destroy == true) ? element.remove() : $animate.leave(element);
286+
return ((options.$destroy == true) ? element.remove() : $animate.leave(element))
287+
.then(function () {
288+
if ($mdUtil.hasComputedStyle(options.parent, 'position', 'static')) {
289+
options.parent.css('position', '');
290+
}
291+
});
281292
}
282293

283294
function toastOpenClass(position) {

0 commit comments

Comments
 (0)