Xamarin.Forms
Xamarin.Forms copied to clipboard
[Bug] iOS Setting FlyoutItem IsVisible to false blocks loading of modal views
Description
After upgrading to Xamarin.Forms 5 we encountered a strange issue: We have a use case in our app where we want to hide a FlyoutItem on demand therefore the IsVisible property is bound to a ViewModel property. When setting the property to false it now blocks all modal pages pushed via Shell.Current.Navigation.PushModalAsync() from being displayed. You can see that the page is loaded, but it is never shown on screen. Making the FlyoutItem visible again returns everything to normal operation. This occurs only on iOS.
Steps to Reproduce
See description above.
Expected Behavior
Modal views should be visible even if a FlyoutItem is set to be not visible.
Actual Behavior
Modal views are not visible when a FlyoutItem is set to not visible.
Basic Information
- Version with issue: 5.0.0.2012 and above
- Last known good version: 4.8.0.1821
- Platform Target Frameworks:
- iOS: 15.2
- NuGet Packages:
- Affected Devices: iPhones
Environment
Show/Hide Visual Studio info
Visual Studio Community 2019 for Mac Version 8.10.17 (build 2) Installation UUID: eb5dba2d-bed2-49ed-af10-410cb4cd09f4 GTK+ 2.24.23 (Raleigh theme) Xamarin.Mac 6.18.0.23 (d16-6 / 088c73638)
Package version: 612000162
Mono Framework MDK Runtime: Mono 6.12.0.162 (2020-02/2ca650f1f62) (64-bit) Package version: 612000162
Roslyn (Language Service) 3.10.0-4.21269.26+029847714208ebe49668667c60ea5b0a294e0fcb
NuGet Version: 5.9.0.7134
.NET SDK (x64) SDK: /usr/local/share/dotnet/sdk/6.0.101/Sdks SDK Versions: 6.0.101 6.0.100 6.0.100-rc.1.21463.6 5.0.404 5.0.403 5.0.402 5.0.401 5.0.400 5.0.302 5.0.301 5.0.203 3.1.416 3.1.415 3.1.414 3.1.413 3.1.412 3.1.411 3.1.410 3.1.409 MSBuild SDKs: /Applications/Visual Studio.app/Contents/Resources/lib/monodevelop/bin/MSBuild/Current/bin/Sdks
.NET Core Runtime Runtime: /usr/local/share/dotnet/dotnet Runtime Versions: 6.0.1 6.0.0 6.0.0-rc.1.21451.13 5.0.13 5.0.12 5.0.11 5.0.10 5.0.9 5.0.8 5.0.7 5.0.6 3.1.22 3.1.21 3.1.20 3.1.19 3.1.18 3.1.17 3.1.16 3.1.15
Xamarin.Profiler Version: 1.7.0.0 Location: /Applications/Xamarin Profiler.app/Contents/MacOS/Xamarin Profiler
Updater Version: 11
Xamarin Designer Version: 16.11.0.60 Hash: 56f9b80b0 Branch: remotes/origin/d16-11 Build date: 2021-12-15 02:44:16 UTC
Apple Developer Tools Xcode 13.2.1 (19586) Build 13C100
Xamarin.Mac Version: 8.4.0.0 (Visual Studio Community) Hash: 8fc41ae82 Branch: xcode13.2 Build date: 2021-12-09 01:07:56-0500
Xamarin.iOS Version: 15.4.0.0 (Visual Studio Community) Hash: 8fc41ae82 Branch: xcode13.2 Build date: 2021-12-09 01:07:56-0500
Xamarin.Android Version: 12.0.0.3 (Visual Studio Community) Commit: xamarin-android/d16-11/f0e3c2d Android SDK: /Users/bastian.noffer/Library/Developer/Xamarin/android-sdk-macosx Supported Android versions: None installed
SDK Tools Version: 26.1.1 SDK Platform Tools Version: 31.0.2 SDK Build Tools Version: 30.0.3
Build Information: Mono: c633fe9 Java.Interop: xamarin/java.interop/d16-11@476bb5b ProGuard: Guardsquare/proguard/v7.0.1@912d149 SQLite: xamarin/sqlite/3.35.4@85460d3 Xamarin.Android Tools: xamarin/xamarin-android-tools/d16-11@87af37b
Eclipse Temurin JDK Java SDK: Not Found
Android SDK Manager Version: 16.10.0.13 Hash: 1b81df5 Branch: remotes/origin/d16-10 Build date: 2021-11-12 01:17:32 UTC
Android Device Manager Version: 16.10.0.15 Hash: 89dcc0b Branch: remotes/origin/d16-10 Build date: 2021-11-12 01:17:52 UTC
Build Information Release ID: 810170002 Git revision: 58f7763d4d64fcf005a474d25a5d9fd5ce46d7f5 Build date: 2022-01-05 12:51:28-05 Build branch: release-8.10
Operating System Mac OS X 11.6.2 Darwin 20.6.0 Darwin Kernel Version 20.6.0 Wed Nov 10 22:23:07 PST 2021 root:xnu-7195.141.14~1/RELEASE_X86_64 x86_64
Enabled user installed extensions DeepClean 1.2.5 NuGet Package Management Extensions 0.27 Template Creator 0.5 Open With 0.2
Reproduction Link
Sample Project: https://github.com/bnoffer/xamarin-iussee-flyoutmodal In order to to show the behavior manipulate the variable in this line: https://github.com/bnoffer/xamarin-iussee-flyoutmodal/blob/815ea33726258c2cb698c00718cb0115d3a1b4d4/FlyoutModalIssue/AppShellViewModel.cs#L26
Same issue for me. Any plan to fix it in a soon release?
We had to implement an ugly workaround for this (disable instead and blank out the title & icon). Are there any plans on addressing this?
We had to implement an ugly workaround for this (disable instead and blank out the title & icon). Are there any plans on addressing this?
@anotherlab, have you found any workaround for this?
For anyone who is still having trouble with this, I found a potential workaround that might be suitable. Of course, if there is a more practical option, please share.
<Shell.FlyoutContent>
<StackLayout BackgroundColor="White" Spacing="3" Padding="5">
<Button x:Name="selectProject" Text="Select Project" ImageSource="{StaticResource project}" BackgroundColor="Transparent" HorizontalOptions="StartAndExpand"
Command="{Binding FlyoutButtonTappedCommand}" CommandParameter="selectProject" />
<Button x:Name="checklist" Text="Checklist" ImageSource="{StaticResource checklist}" BackgroundColor="Transparent" HorizontalOptions="StartAndExpand"
Command="{Binding FlyoutButtonTappedCommand}" CommandParameter="checklist" />
<Button x:Name="schedule" Text="Schedule" ImageSource="{StaticResource schedule}" BackgroundColor="Transparent" HorizontalOptions="StartAndExpand"
Command="{Binding FlyoutButtonTappedCommand}" CommandParameter="schedule" />
</StackLayout>
</Shell.FlyoutContent>
Each button can easily be hidden and the PushModalAsync works as expected.
The command 'FlyoutButtonTappedCommand' is basically a switch statement that navigates the user to a page that is determined by the CommandParameter. After the switch statement is completed, the flyout is programmatically closed.