Snackbar expands when soft keyboard is showing

I have noticed that this only happens when the Snackbar is attached to a CoordinatorLayout that has ANOTHER CoordinatorLayout parent somewhere up the hierarchy. I guess the behaviour of <add as much bottom padding as needed to display the Snackbar above the keyboard> gets duplicated because of the multiple CoordinatorLayouts, and the Snackbar ends up taking the entire screen.

The solution is to attach the Snackbar to the topmost CoordinatorLayout. In my scenario I have an Activity with a CoordinatorLayout content view, that hosts a fragment that has a CoordinatorLayout as the root view. When the fragment needs to display a Snackbar, it attaches it to the Activity's CoordinatorLayout, and then it behaves correctly when the keyboard is displayed. Note that I am now using the AndroidX library instead of the support library, so the behaviour may be slightly different.