material-components / material-components/material-components-android

[Snackbar] Snackbar bottom margin is incorrect when using window insets with padding

Aperta
#3,446 9 commenti 12 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

bug Widget: Snackbar
Lingua principale
Java
Stelle
17.4k
Fork
3.2k
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

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.
Zrzut ekranu 2023-06-9 o 15 54 13

When insets update padding, snackbar gets extra bottom margin. It seems that navigation bar height is used twice.
Zrzut ekranu 2023-06-9 o 15 54 27

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

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

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.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
android, java
Ambito
mobile
Tipo di issue
Bug
Difficoltà
4/5
Tempo stimato
3-5 giorni
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
42/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.