-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Fix for picker on hidden page opens after back navigation in Android #25319
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
Conversation
… only pop up when tapped or the Enter key is pressed.
|
/azp run |
|
Azure Pipelines successfully started running 3 pipeline(s). |
|
Azure Pipelines successfully started running 3 pipeline(s). |
|
/azp run |
|
Azure Pipelines successfully started running 3 pipeline(s). |
|
/rebase |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately, I don't think we'll be able to take this PR as is.
I wish on the PR you referenced we would have also applied this logic to Picker but since we didn't, this isn't really a behavior we can change right now especially if there isn't a replace API to open the picker from code.
My current thought here is
- We can keep this code how it currently is
- We try to add code so that if the user calls "Focus" directly then we have that trigger the opening of the picker.
@PureWeen, Thank you for the feedback. I understand the limitations here. I'll keep the current code as is and look into alternative solutions for this issue. |
|
/rebase |
|
/azp run |
|
Azure Pipelines successfully started running 3 pipeline(s). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The build is failing:
C:\a\_work\1\s\src\Controls\samples\Controls.Sample\Pages\UserInterface\VisualStatesPage.xaml(56,34): XamlC warning XC0022: Binding could be compiled to improve runtime performance if x:DataType is specified. See https://learn.microsoft.com/dotnet/maui/fundamentals/data-binding/compiled-bindings for more information. [C:\a\_work\1\s\src\Controls\samples\Controls.Sample\Maui.Controls.Sample.csproj::TargetFramework=net9.0-windows10.0.20348.0]
C:\a\_work\1\s\src\Controls\tests\TestCases.HostApp\Issues\Issue24862.cs(12,15): error CS0101: The namespace 'Maui.Controls.Sample.Issues' already contains a definition for 'MainPage' [C:\a\_work\1\s\src\Controls\tests\TestCases.HostApp\Controls.TestCases.HostApp.csproj::TargetFramework=net9.0-maccatalyst]
C:\a\_work\1\s\src\Controls\tests\TestCases.HostApp\Issues\Issue24862.cs(14,10): error CS0111: Type 'MainPage' already defines a member called 'MainPage' with the same parameter types [C:\a\_work\1\s\src\Controls\tests\TestCases.HostApp\Controls.TestCases.HostApp.csproj::TargetFramework=net9.0-maccatalyst]
C:\a\_work\1\s\src\Controls\tests\TestCases.HostApp\Issues\Issue24862.cs(12,15): error CS0101: The namespace 'Maui.Controls.Sample.Issues' already contains a definition for 'MainPage' [C:\a\_work\1\s\src\Controls\tests\TestCases.HostApp\Controls.TestCases.HostApp.csproj::TargetFramework=net9.0-ios]
C:\a\_work\1\s\src\Controls\tests\TestCases.HostApp\Issues\Issue24862.cs(14,10): error CS0111: Type 'MainPage' already defines a member called 'MainPage' with the same parameter types [C:\a\_work\1\s\src\Controls\tests\TestCases.HostApp\Controls.TestCases.HostApp.csproj::TargetFramework=net9.0-ios]
C:\a\_work\1\s\src\Controls\tests\TestCases.HostApp\Issues\Issue24862.cs(12,15): error CS0101: The namespace 'Maui.Controls.Sample.Issues' already contains a definition for 'MainPage' [C:\a\_work\1\s\src\Controls\tests\TestCases.HostApp\Controls.TestCases.HostApp.csproj::TargetFramework=net9.0-tizen]
C:\a\_work\1\s\src\Controls\tests\TestCases.HostApp\Issues\Issue24862.cs(14,10): error CS0111: Type 'MainPage' already defines a member called 'MainPage' with the same parameter types [C:\a\_work\1\s\src\Controls\tests\TestCases.HostApp\Controls.TestCases.HostApp.csproj::TargetFramework=net9.0-tizen]
C:\a\_work\1\s\src\Controls\tests\TestCases.HostApp\Issues\Issue24862.cs(12,15): error CS0101: The namespace 'Maui.Controls.Sample.Issues' already contains a definition for 'MainPage' [C:\a\_work\1\s\src\Controls\tests\TestCases.HostApp\Controls.TestCases.HostApp.csproj::TargetFramework=net9.0-android]
C:\a\_work\1\s\src\Controls\tests\TestCases.HostApp\Issues\Issue24862.cs(14,10): error CS0111: Type 'MainPage' already defines a member called 'MainPage' with the same parameter types [C:\a\_work\1\s\src\Controls\tests\TestCases.HostApp\Controls.TestCases.HostApp.csproj::TargetFramework=net9.0-android]
C:\a\_work\1\s\src\Controls\tests\TestCases.HostApp\Issues\Issue24862.cs(12,15): error CS0101: The namespace 'Maui.Controls.Sample.Issues' already contains a definition for 'MainPage' [C:\a\_work\1\s\src\Controls\tests\TestCases.HostApp\Controls.TestCases.HostApp.csproj::TargetFramework=net9.0-windows10.0.20348.0]
C:\a\_work\1\s\src\Controls\tests\TestCases.HostApp\Issues\Issue24862.cs(14,10): error CS0111: Type 'MainPage' already defines a member called 'MainPage' with the same parameter types [C:\a\_work\1\s\src\Controls\tests\TestCases.HostApp\Controls.TestCases.HostApp.csproj::TargetFramework=net9.0-windows10.0.20348.0]
C:\a\_work\1\s\src\Controls\tests\TestCases.HostApp\Issues\Issue24862.cs(12,15): error CS0101: The namespace 'Maui.Controls.Sample.Issues' already contains a definition for 'MainPage' [C:\a\_work\1\s\src\Controls\tests\TestCases.HostApp\Controls.TestCases.HostApp.csproj::TargetFramework=net9.0-windows10.0.19041.0]
C:\a\_work\1\s\src\Controls\tests\TestCases.HostApp\Issues\Issue24862.cs(14,10): error CS0111: Type 'MainPage' already defines a member called 'MainPage' with the same parameter types [C:\a\_work\1\s\src\Controls\tests\TestCases.HostApp\Controls.TestCases.HostApp.csproj::TargetFramework=net9.0-windows10.0.19041.0]
12 Error(s)
| } | ||
| } | ||
|
|
||
| public class MainPage : ContentPage |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rename to something like Issue24862MainPage.
|
Closing in favor of #29068 |
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.
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
24862-BeforeFix.mp4
24862-AfterFix.mp4