Skip to content

Commit 763db37

Browse files
committed
fix(snackbar): android options.view can be any view now
1 parent 22bb917 commit 763db37

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/snackbar/snackbar.android.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ export class SnackBar extends SnackBarBase {
5656
attachView = modalViews[modalViews.length - 1] as View;
5757
}
5858
}
59-
const page = attachView instanceof Page ? attachView : attachView.page;
60-
let nView = (page.nativeViewProtected as android.view.View).getParent();
59+
const page = (attachView instanceof Page ? attachView : attachView.page) || attachView;
60+
let nView = page instanceof Page ? (page.nativeViewProtected as android.view.View).getParent() : attachView.nativeViewProtected;
6161
let nCoordinatorLayout: androidx.coordinatorlayout.widget.CoordinatorLayout = (page as any).nCoordinatorLayout;
6262
if (!nCoordinatorLayout && !(nView instanceof androidx.coordinatorlayout.widget.CoordinatorLayout) && nView instanceof android.view.ViewGroup) {
6363
nCoordinatorLayout = new androidx.coordinatorlayout.widget.CoordinatorLayout(attachView._context);
@@ -76,7 +76,7 @@ export class SnackBar extends SnackBarBase {
7676

7777
nView = nCoordinatorLayout;
7878
}
79-
this._snackbar = com.google.android.material.snackbar.Snackbar.make(nView as any, options.message, options.hideDelay);
79+
this._snackbar = com.google.android.material.snackbar.Snackbar.make(nView, options.message, options.hideDelay);
8080
if (options.anchorView) {
8181
this._snackbar.setAnchorView(options.anchorView.nativeViewProtected);
8282
}

0 commit comments

Comments
 (0)