material-components / material-components/material-components-android
[Snackbar] Snackbar bottom margin is incorrect when using window insets with padding
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 17.4k
- Forks
- 3.2k
- PR merge metrics
- No merged PRs in 30d
Description
**Description:**
Snackbar with anchor has incorrect bottom margin when window insets are used that set container padding instead of margin.
When insets update margin, snackbar is shown correctly above the anchor button.
When insets update padding, snackbar gets extra bottom margin. It seems that navigation bar height is used twice.
**Expected behavior:** Snackbar should always be displayed right above the anchor.
**Source code:**
The issue is most probably somewhere in `BaseTransientBottomBar`, but I wasn't able to identify exact place.
**Minimal sample app repro:**
https://github.com/aleksandra-krzemien/nested-nav-graphs-example/tree/krzemien/snackbar-inset-handling
Tap on `to first fragment` button to open `FirstFragment`. Current code will use insets with margin, so you will see situation on the first screenshot above (correct).
If you comment `FirstFragment` lines 41-43 and uncomment line 45, insets will update padding, and you'll end up with situation from second screenshot (incorrect).
**Android API version:** 29
**Material Library version:** 1.9.0
**Device:** Pixel 4a
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the issue with the linked nested-nav-graphs-example sample, comparing the margin and padding inset handling described for FirstFragment lines 41-45. Then inspect BaseTransientBottomBar to trace how the anchor position and navigation bar inset affect the Snackbar bottom margin. Done means the Snackbar appears directly above its anchor in both inset configurations, with regression coverage for each case.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- android, java
- Domain
- mobile
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100