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

[BottomSheet] PeekHeight measured incorrectly during first layout when marginTopSystemWindowInsets is set to true

Open
#3,380 2 comments 8 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug Widget: BottomSheet
Dominant language
Java
Stars
17.4k
Forks
3.2k
PR merge metrics
No merged PRs in 30d

Description

**Description:**

When application is in edge-to-edge mode, it is expected that `peekHeight` will be increased by the bottom system window inset when `paddingBottomSystemWindowInsets=true`. However, if you set `marginTopSystemWindowInsets` to `true` at the same time, then at first `peekHeight` is going to be measured incorrectly - it'll be decreased by the size of the top inset. Once you expand the sheet and collapse it again, it'll be collapsed to the correctly measured peek height.

**Expected behavior:**

Peek height should be not effected by the top system window inset, when `marginTopSystemWindowInsets=true` during every layout.

I suspect that https://github.com/material-components/material-components-android/pull/2094 might fix the issue.

**Source code:**

Here's the project which demonstrates the issue https://github.com/Lingviston/bottom-sheet-peek-height-bu/tree/master

The short recording can be found there in /demo folder.

**Android API version:** Any

**Material Library version:** 1.9.0

**Device:** Pixel 4 API 28, Pixel 2 API 31

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the linked bottom-sheet-peek-height-bu reproduction project and the recording in its /demo folder. Reproduce the first-layout behavior with both system-inset options enabled, then inspect the BottomSheet implementation and relevant tests to identify where the top inset affects peekHeight. Done means the initial and subsequent collapsed layouts use the same correctly inset-adjusted peek height.

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
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.