Skip to content

[Android] Fix DatePicker dialog dismisses after the device is rotated#34980

Merged
kubaflo merged 3 commits into
dotnet:inflight/currentfrom
HarishwaranVijayakumar:fix-datepickerdialogdismiss
May 20, 2026
Merged

[Android] Fix DatePicker dialog dismisses after the device is rotated#34980
kubaflo merged 3 commits into
dotnet:inflight/currentfrom
HarishwaranVijayakumar:fix-datepickerdialogdismiss

Conversation

@HarishwaranVijayakumar

Copy link
Copy Markdown
Contributor

Note

Are you waiting for the changes in this PR to be merged?
It would be very helpful if you could test the resulting artifacts from this PR and let us know in a comment if this change resolves your issue. Thank you!

Issue Details

  • The DatePicker dialog is dismissed when the device is rotated while the dialog is open.

Root Cause of the issue

  • PR 29323 added DismissEvent subscription in CreateDatePickerDialog() and an OnDialogDismiss → HidePickerDialog() chain that sets IsOpen = false.
  • On rotation, OnMainDisplayInfoChanged unsubscribes DismissEvent and calls Dismiss().
  • ShowPickerDialog() runs synchronously after Dismiss(), enters the else branch, and re-subscribes DismissEvent on the same dialog.
  • The DismissEvent from step 2 fires after re-subscription, triggering HidePickerDialog() which dismisses the newly-shown dialog.
  • Before PR 29323: There was no DismissEvent subscription, no IsOpen property, and no OnDialogDismiss handler — so the dismiss-and-re-show flow in OnMainDisplayInfoChanged worked without interference.

Description of Change

Dialog lifecycle and event handling improvements:

  • Renamed ResetDialog() to DestroyDialog() and updated all references accordingly to clarify its purpose and ensure consistent dialog destruction and recreation.
  • Removed unnecessary subscriptions and unsubscriptions to the dialog's DismissEvent, simplifying dialog event handling in both ShowPickerDialog() and HidePickerDialog().

Display info change handling:

  • Improved the logic in OnMainDisplayInfoChanged to properly destroy and recreate the dialog with the current date, ensuring the dialog updates correctly when display information changes (such as orientation changes).

Issues Fixed

Fixes #34973

Tested the behaviour in the following platforms

  • - Windows
  • - Android
  • - iOS
  • - Mac
Before After
Before_fixdatepicker.mov
After_fixdatepicker.mov

@github-actions

github-actions Bot commented Apr 15, 2026

Copy link
Copy Markdown
Contributor

🚀 Dogfood this PR with:

⚠️ WARNING: Do not do this without first carefully reviewing the code of this PR to satisfy yourself it is safe.

curl -fsSL https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.sh | bash -s -- 34980

Or

  • Run remotely in PowerShell:
iex "& { $(irm https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.ps1) } 34980"

@dotnet-policy-service dotnet-policy-service Bot added the community ✨ Community Contribution label Apr 15, 2026
@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Hey there @@HarishwaranVijayakumar! Thank you so much for your PR! Someone from the team will get assigned to your PR shortly and we'll get it reviewed.

@dotnet-policy-service dotnet-policy-service Bot added the partner/syncfusion Issues / PR's with Syncfusion collaboration label Apr 15, 2026
@sheiksyedm sheiksyedm marked this pull request as ready for review April 15, 2026 14:32
Copilot AI review requested due to automatic review settings April 15, 2026 14:32

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes an Android regression where the DatePicker dialog immediately dismisses after device rotation by adjusting the dialog lifecycle to avoid re-triggering the dialog’s dismiss handling during the rotation re-show flow.

Changes:

  • Renamed ResetDialog() to DestroyDialog() and updated call sites to better reflect behavior (dismiss + null-out).
  • Simplified DismissEvent wiring by removing per-show/per-hide subscribe/unsubscribe and keeping it scoped to dialog creation/destruction.
  • Updated OnMainDisplayInfoChanged to capture the currently selected date, destroy the existing dialog, and recreate/show a new dialog with the captured date.

@MauiBot MauiBot added s/agent-changes-requested AI agent recommends changes - found a better alternative or issues s/agent-fix-pr-picked AI could not beat the PR fix - PR is the best among all candidates s/agent-reviewed PR was reviewed by AI agent workflow (full 4-phase review) labels Apr 15, 2026
@dotnet dotnet deleted a comment from MauiBot Apr 17, 2026
@dotnet dotnet deleted a comment from MauiBot Apr 17, 2026
@kubaflo

kubaflo commented Apr 17, 2026

Copy link
Copy Markdown
Contributor

/azp run maui-pr-uitests , maui-pr-devicetests

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 2 pipeline(s).

@kubaflo

kubaflo commented May 19, 2026

Copy link
Copy Markdown
Contributor

/review -b feature/regression-check -p android

1 similar comment
@kubaflo

kubaflo commented May 19, 2026

Copy link
Copy Markdown
Contributor

/review -b feature/regression-check -p android

@dotnet dotnet deleted a comment from MauiBot May 19, 2026
@kubaflo

kubaflo commented May 19, 2026

Copy link
Copy Markdown
Contributor

/review -b feature/regression-check -p android

@kubaflo kubaflo changed the base branch from main to inflight/current May 20, 2026 10:10
@kubaflo kubaflo merged commit 3b51fff into dotnet:inflight/current May 20, 2026
140 of 169 checks passed
@github-actions github-actions Bot added this to the .NET 10.0 SR8 milestone May 20, 2026
@kubaflo kubaflo added the s/agent-gate-failed AI could not verify tests catch the bug label May 20, 2026
@dotnet dotnet deleted a comment from MauiBot May 20, 2026
@kubaflo

kubaflo commented May 20, 2026

Copy link
Copy Markdown
Contributor

/review -b feature/regression-check -p android

devanathan-vaithiyanathan pushed a commit to devanathan-vaithiyanathan/maui that referenced this pull request Jun 1, 2026
…ability (dotnet#35133)

<!-- Please let the below note in for people that find this PR -->
> [!NOTE]
> Are you waiting for the changes in this PR to be merged?
> It would be very helpful if you could [test the resulting
artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from
this PR and let us know in a comment if this change resolves your issue.
Thank you!

> **Depends on dotnet#35136** (pipeline category detection — should merge
first)

## What this does

Two things:

### 1. UI test category detection in PR review

During the PR review workflow, Step 0.5 detects which UI test categories
the PR impacts and writes the result to the AI summary comment. This
gives reviewers visibility into which UI tests are relevant.

**Detection** reuses the 3-tier script from dotnet#35136 (test attributes →
source paths → AI reasoning).

**AI summary** shows a new 🧪 UI Tests section with detected categories
before the gate section.

### 2. Gate reliability fixes

Multiple fixes to make the gate (`verify-tests-fail.ps1`) more
deterministic:

| Fix | Problem it solves |
|-----|-------------------|
| **Absolute path resolution** | Gate scripts not found on Linux CI
agents (`Resolve-Path`, `GetFullPath`) |
| **File existence check** | Instant cryptic failure when verify script
is missing — now logs clear error |
| **3x retry on ENV ERROR** | Emulator timeouts, ADB failures, app
crashes — transient issues that pass on retry |
| **Strip bad report blocks** | Old verify script produces `Passed:
False` with empty counts — stripped instead of shown |
| **Gate log in fallback** | When report is missing, shows last 20 lines
of gate output instead of just `❌ FAILED / Platform: IOS` |

## Files

| File | Changes |
|------|---------|
| `.github/scripts/Review-PR.ps1` | Step 0.5 category detection + all 5
gate fixes |
| `.github/scripts/post-ai-summary-comment.ps1` | Add `uitests` phase to
render detected categories |
| `.github/pr-review/pr-preflight.md` | Step 7: AI identifies impacted
UI test categories |

## Validation — PR reviewer builds (Apr 26)

10 builds against real PRs — all succeeded ✅. Category detection shown
in AI summary comment.

| PR | Categories Detected | Build | AI Summary |
|----|-------------------|-------|------------|
| dotnet#35037 (WebView theme) | `ViewBaseTests,WebView` |
[13940071](https://devdiv.visualstudio.com/DevDiv/_build/results?buildId=13940071)
|
[comment](dotnet#35037 (comment))
|
| dotnet#35031 (Shell memory leak) | `Shell` |
[13940072](https://devdiv.visualstudio.com/DevDiv/_build/results?buildId=13940072)
|
[comment](dotnet#35031 (comment))
|
| dotnet#35020 (XAML Hot Reload) | _(none — XAML only)_ |
[13940073](https://devdiv.visualstudio.com/DevDiv/_build/results?buildId=13940073)
| ✅ Shows "No UI test categories" |
| dotnet#35008 (Shell SearchHandler) | `Shell` |
[13940074](https://devdiv.visualstudio.com/DevDiv/_build/results?buildId=13940074)
| ✅ |
| dotnet#34997 (RadioButton gradient) | `RadioButton,ViewBaseTests` |
[13940075](https://devdiv.visualstudio.com/DevDiv/_build/results?buildId=13940075)
| ✅ |
| dotnet#34980 (DatePicker rotation) | `ViewBaseTests` |
[13940076](https://devdiv.visualstudio.com/DevDiv/_build/results?buildId=13940076)
| ✅ |
| dotnet#34974 (Picker CharacterSpacing) | `ViewBaseTests` |
[13940077](https://devdiv.visualstudio.com/DevDiv/_build/results?buildId=13940077)
| ✅ |
| dotnet#34923 (SwipeView threshold) | `SwipeView,ViewBaseTests` |
[13940078](https://devdiv.visualstudio.com/DevDiv/_build/results?buildId=13940078)
| ✅ |
| dotnet#34907 (CollectionView ScrollTo) | `CollectionView` |
[13940079](https://devdiv.visualstudio.com/DevDiv/_build/results?buildId=13940079)
| ✅ |
| dotnet#34845 (RefreshView binding) | `RefreshView,ViewBaseTests` |
[13940080](https://devdiv.visualstudio.com/DevDiv/_build/results?buildId=13940080)
| ✅ |

---------

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
PureWeen pushed a commit that referenced this pull request Jun 2, 2026
…#34980)

<!-- Please let the below note in for people that find this PR -->
> [!NOTE]
> Are you waiting for the changes in this PR to be merged?
> It would be very helpful if you could [test the resulting
artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from
this PR and let us know in a comment if this change resolves your issue.
Thank you!
<!--
!!!!!!! MAIN IS THE ONLY ACTIVE BRANCH. MAKE SURE THIS PR IS TARGETING
MAIN. !!!!!!!
-->
### Issue Details

- The DatePicker dialog is dismissed when the device is rotated while
the dialog is open.

### Root Cause of the issue

- PR [29323](#29323) added
DismissEvent subscription in CreateDatePickerDialog() and an
OnDialogDismiss → HidePickerDialog() chain that sets IsOpen = false.
- On rotation, OnMainDisplayInfoChanged unsubscribes DismissEvent and
calls Dismiss().
- ShowPickerDialog() runs synchronously after Dismiss(), enters the else
branch, and re-subscribes DismissEvent on the same dialog.
- The DismissEvent from step 2 fires after re-subscription, triggering
HidePickerDialog() which dismisses the newly-shown dialog.
- Before PR [29323](#29323): There
was no DismissEvent subscription, no IsOpen property, and no
OnDialogDismiss handler — so the dismiss-and-re-show flow in
OnMainDisplayInfoChanged worked without interference.


### Description of Change

**Dialog lifecycle and event handling improvements:**

* Renamed `ResetDialog()` to `DestroyDialog()` and updated all
references accordingly to clarify its purpose and ensure consistent
dialog destruction and recreation.
* Removed unnecessary subscriptions and unsubscriptions to the dialog's
`DismissEvent`, simplifying dialog event handling in both
`ShowPickerDialog()` and `HidePickerDialog()`.

**Display info change handling:**

* Improved the logic in `OnMainDisplayInfoChanged` to properly destroy
and recreate the dialog with the current date, ensuring the dialog
updates correctly when display information changes (such as orientation
changes).

### Issues Fixed

<!-- Please make sure that there is a bug logged for the issue being
fixed. The bug should describe the problem and how to reproduce it. -->

Fixes #34973 

### Tested the behaviour in the following platforms

- [ ] - Windows 
- [x] - Android
- [ ] - iOS
- [ ] - Mac

| Before | After |
|----------|----------|
| <video
src="https://github.com/user-attachments/assets/c5de443c-371d-4b48-9623-9a17965ba5c3">
| <video
src="https://github.com/user-attachments/assets/014ac4eb-7958-488b-bfad-4e3c6ef69796">
|







<!--
Are you targeting main? All PRs should target the main branch unless
otherwise noted.
-->
devanathan-vaithiyanathan pushed a commit to devanathan-vaithiyanathan/maui that referenced this pull request Jun 5, 2026
…ability (dotnet#35133)

<!-- Please let the below note in for people that find this PR -->
> [!NOTE]
> Are you waiting for the changes in this PR to be merged?
> It would be very helpful if you could [test the resulting
artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from
this PR and let us know in a comment if this change resolves your issue.
Thank you!

> **Depends on dotnet#35136** (pipeline category detection — should merge
first)

## What this does

Two things:

### 1. UI test category detection in PR review

During the PR review workflow, Step 0.5 detects which UI test categories
the PR impacts and writes the result to the AI summary comment. This
gives reviewers visibility into which UI tests are relevant.

**Detection** reuses the 3-tier script from dotnet#35136 (test attributes →
source paths → AI reasoning).

**AI summary** shows a new 🧪 UI Tests section with detected categories
before the gate section.

### 2. Gate reliability fixes

Multiple fixes to make the gate (`verify-tests-fail.ps1`) more
deterministic:

| Fix | Problem it solves |
|-----|-------------------|
| **Absolute path resolution** | Gate scripts not found on Linux CI
agents (`Resolve-Path`, `GetFullPath`) |
| **File existence check** | Instant cryptic failure when verify script
is missing — now logs clear error |
| **3x retry on ENV ERROR** | Emulator timeouts, ADB failures, app
crashes — transient issues that pass on retry |
| **Strip bad report blocks** | Old verify script produces `Passed:
False` with empty counts — stripped instead of shown |
| **Gate log in fallback** | When report is missing, shows last 20 lines
of gate output instead of just `❌ FAILED / Platform: IOS` |

## Files

| File | Changes |
|------|---------|
| `.github/scripts/Review-PR.ps1` | Step 0.5 category detection + all 5
gate fixes |
| `.github/scripts/post-ai-summary-comment.ps1` | Add `uitests` phase to
render detected categories |
| `.github/pr-review/pr-preflight.md` | Step 7: AI identifies impacted
UI test categories |

## Validation — PR reviewer builds (Apr 26)

10 builds against real PRs — all succeeded ✅. Category detection shown
in AI summary comment.

| PR | Categories Detected | Build | AI Summary |
|----|-------------------|-------|------------|
| dotnet#35037 (WebView theme) | `ViewBaseTests,WebView` |
[13940071](https://devdiv.visualstudio.com/DevDiv/_build/results?buildId=13940071)
|
[comment](dotnet#35037 (comment))
|
| dotnet#35031 (Shell memory leak) | `Shell` |
[13940072](https://devdiv.visualstudio.com/DevDiv/_build/results?buildId=13940072)
|
[comment](dotnet#35031 (comment))
|
| dotnet#35020 (XAML Hot Reload) | _(none — XAML only)_ |
[13940073](https://devdiv.visualstudio.com/DevDiv/_build/results?buildId=13940073)
| ✅ Shows "No UI test categories" |
| dotnet#35008 (Shell SearchHandler) | `Shell` |
[13940074](https://devdiv.visualstudio.com/DevDiv/_build/results?buildId=13940074)
| ✅ |
| dotnet#34997 (RadioButton gradient) | `RadioButton,ViewBaseTests` |
[13940075](https://devdiv.visualstudio.com/DevDiv/_build/results?buildId=13940075)
| ✅ |
| dotnet#34980 (DatePicker rotation) | `ViewBaseTests` |
[13940076](https://devdiv.visualstudio.com/DevDiv/_build/results?buildId=13940076)
| ✅ |
| dotnet#34974 (Picker CharacterSpacing) | `ViewBaseTests` |
[13940077](https://devdiv.visualstudio.com/DevDiv/_build/results?buildId=13940077)
| ✅ |
| dotnet#34923 (SwipeView threshold) | `SwipeView,ViewBaseTests` |
[13940078](https://devdiv.visualstudio.com/DevDiv/_build/results?buildId=13940078)
| ✅ |
| dotnet#34907 (CollectionView ScrollTo) | `CollectionView` |
[13940079](https://devdiv.visualstudio.com/DevDiv/_build/results?buildId=13940079)
| ✅ |
| dotnet#34845 (RefreshView binding) | `RefreshView,ViewBaseTests` |
[13940080](https://devdiv.visualstudio.com/DevDiv/_build/results?buildId=13940080)
| ✅ |

---------

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
PureWeen pushed a commit that referenced this pull request Jun 11, 2026
…#34980)

<!-- Please let the below note in for people that find this PR -->
> [!NOTE]
> Are you waiting for the changes in this PR to be merged?
> It would be very helpful if you could [test the resulting
artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from
this PR and let us know in a comment if this change resolves your issue.
Thank you!
<!--
!!!!!!! MAIN IS THE ONLY ACTIVE BRANCH. MAKE SURE THIS PR IS TARGETING
MAIN. !!!!!!!
-->
### Issue Details

- The DatePicker dialog is dismissed when the device is rotated while
the dialog is open.

### Root Cause of the issue

- PR [29323](#29323) added
DismissEvent subscription in CreateDatePickerDialog() and an
OnDialogDismiss → HidePickerDialog() chain that sets IsOpen = false.
- On rotation, OnMainDisplayInfoChanged unsubscribes DismissEvent and
calls Dismiss().
- ShowPickerDialog() runs synchronously after Dismiss(), enters the else
branch, and re-subscribes DismissEvent on the same dialog.
- The DismissEvent from step 2 fires after re-subscription, triggering
HidePickerDialog() which dismisses the newly-shown dialog.
- Before PR [29323](#29323): There
was no DismissEvent subscription, no IsOpen property, and no
OnDialogDismiss handler — so the dismiss-and-re-show flow in
OnMainDisplayInfoChanged worked without interference.


### Description of Change

**Dialog lifecycle and event handling improvements:**

* Renamed `ResetDialog()` to `DestroyDialog()` and updated all
references accordingly to clarify its purpose and ensure consistent
dialog destruction and recreation.
* Removed unnecessary subscriptions and unsubscriptions to the dialog's
`DismissEvent`, simplifying dialog event handling in both
`ShowPickerDialog()` and `HidePickerDialog()`.

**Display info change handling:**

* Improved the logic in `OnMainDisplayInfoChanged` to properly destroy
and recreate the dialog with the current date, ensuring the dialog
updates correctly when display information changes (such as orientation
changes).

### Issues Fixed

<!-- Please make sure that there is a bug logged for the issue being
fixed. The bug should describe the problem and how to reproduce it. -->

Fixes #34973 

### Tested the behaviour in the following platforms

- [ ] - Windows 
- [x] - Android
- [ ] - iOS
- [ ] - Mac

| Before | After |
|----------|----------|
| <video
src="https://github.com/user-attachments/assets/c5de443c-371d-4b48-9623-9a17965ba5c3">
| <video
src="https://github.com/user-attachments/assets/014ac4eb-7958-488b-bfad-4e3c6ef69796">
|







<!--
Are you targeting main? All PRs should target the main branch unless
otherwise noted.
-->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-controls-datetimepicker DatePicker, TimePicker community ✨ Community Contribution partner/syncfusion Issues / PR's with Syncfusion collaboration platform/android s/agent-fix-win AI found a better alternative fix than the PR s/agent-gate-failed AI could not verify tests catch the bug s/agent-reviewed PR was reviewed by AI agent workflow (full 4-phase review)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Android] [Regression] DatePicker dialog dismisses after the device is rotated

6 participants