Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for picker on hidden page opens after back navigation in Android #25319

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

BagavathiPerumal
Copy link
Contributor

@BagavathiPerumal BagavathiPerumal commented Oct 16, 2024

Root cause

The root cause of the issue is that the picker on MainPage unexpectedly opens the Picker dialog popup in FirstPage when navigating back, even though MainPage is not currently visible. This occurs because the Picker's focus changes during navigation back to FirstPage using Navigation.PopModalAsync(), triggering a click operation on the Picker, which opens the dialog regardless of MainPage's visibility.

Description of Issue Fix

The fix involves removing the auto-open behavior on focus from the Pickers by eliminating the FocusChanged event, which handled the Picker's OnClick operation when focus changed. This adjustment prevents the Picker dialog from opening during page navigation.

Specifically, when the Picker gains focus, the previous implementation would trigger PlatformView.CallOnClick() or OnClick(PlatformView, EventArgs.Empty), leading to the unwanted dialog popup. Additionally, the FocusableInTouchMode property is set to false to ensure that the Pickers do not gain focus unexpectedly.

Tested the behavior in the following platforms.

  • Android
  • Windows
  • Mac
  • iOS

Issues Fixed

Fixes #24862

Reference

Similar code changes have been applied to the DatePicker and TimePicker dialogs to enable auto-opening after resolving the navigation issue. The link to the PR containing the changes is mentioned below.

#8913

Output

Before Issue Fix After Issue Fix
24862-BeforeFix.mp4
24862-AfterFix.mp4

… only pop up when tapped or the Enter key is pressed.
@dotnet-policy-service dotnet-policy-service bot added the community ✨ Community Contribution label Oct 16, 2024
Copy link
Contributor

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

@jsuarezruiz
Copy link
Contributor

jsuarezruiz commented Oct 16, 2024

/azp run

Copy link

Azure Pipelines successfully started running 3 pipeline(s).

@BagavathiPerumal BagavathiPerumal marked this pull request as ready for review October 18, 2024 05:27
@BagavathiPerumal BagavathiPerumal requested a review from a team as a code owner October 18, 2024 05:27
Copy link

Azure Pipelines successfully started running 3 pipeline(s).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Android - picker on hidden page opens after back navigation
2 participants