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

[MaterialDatePicker] Selected month is lost when app returns from background

Open
#4,539 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

**Description:** Issue can be reproduced with Catalog app, as seen in attached recording

1. Open DatePicker, and navigate to month in the past or in the future.
2. Put app into background and then bring to foreground
3. DatePicker selection moves back to current month (or the one it was opened with initially)

**Expected behavior:** State of the component should be maintained.

The problem only happens in background/foreground use case. When device is rotated, the state is correctly maintained.

**Android API version:** Observed on multiple versions, e.g. 30 and 35.

**Material Library version:** Catalog app built from HEAD on master branch (690bbfc917b5a31f18d6285a684e39e6ef55dd6a). Also observed with 1.12.0

**Device:** Observed on multiple devices, e.g. Android emulator, Pixel 6a

As a user of my app has reported (https://github.com/mtotschnig/MyExpenses/issues/1626), this has important UX implication: User navigates to a given month, and before selecting the day, they need to verify information in a different app, and when returning to my app, the month they already have selected, is lost.

https://github.com/user-attachments/assets/9c3e3910-a345-4ec4-8a83-1153bb36f6ca

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

Reproduce the issue in the Catalog app by navigating to another month, backgrounding the app, and returning to it. Inspect MaterialDatePicker state handling around background/foreground restoration; done means the selected month remains unchanged, as it does across rotation.

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
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.