maui: [regression/8.0.0-preview.3.8149] Header in flyout menu makes first menu item not clickable on IOS
Description
When you have a shell flyout menu and have no Shell.FlyoutHeader then all the menu items work correctly on both ios and android.
If you add a Shell.FlyoutHeader to the flyout menu then the first flyoutmenu item on IOS is not clickable (android works fine). NOTE: If you remove the Shell.FlyoutHeader then it works fine.
In the example shell.xaml below the first flyoutmenu item named ‘Clicking Me Doesnt Work’ wont work on IOS.
<Shell
x:Class="DEMO.AppShell"
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:pages="clr-namespace:DEMO.Pages"
Shell.FlyoutBehavior="Flyout">
<Shell.Resources>
<ResourceDictionary>
<Style x:Key="BaseStyle" TargetType="Element">
<Setter Property="Shell.BackgroundColor" Value="{StaticResource Primary}" />
<Setter Property="Shell.ForegroundColor" Value="White" />
<Setter Property="Shell.TitleColor" Value="White" />
<Setter Property="Shell.DisabledColor" Value="#B4FFFFFF" />
<Setter Property="Shell.UnselectedColor" Value="{AppThemeBinding Dark=#95FFFFFF, Light=#95000000}" />
<Setter Property="Shell.TabBarBackgroundColor" Value="{AppThemeBinding Dark={StaticResource DarkBackground}, Light={StaticResource LightBackground}}" />
<Setter Property="Shell.TabBarForegroundColor" Value="{AppThemeBinding Dark={StaticResource LightBackground}, Light={StaticResource DarkBackground}}" />
<Setter Property="Shell.TabBarUnselectedColor" Value="{AppThemeBinding Dark=#95FFFFFF, Light=#95000000}" />
<Setter Property="Shell.TabBarTitleColor" Value="{AppThemeBinding Dark={StaticResource LightBackground}, Light={StaticResource DarkBackground}}" />
</Style>
<Style BasedOn="{StaticResource BaseStyle}" TargetType="ShellItem" ApplyToDerivedTypes="True" />
</ResourceDictionary>
</Shell.Resources>
<Shell.FlyoutHeader>
<Grid HorizontalOptions="Fill" VerticalOptions="Start" HeightRequest="250" InputTransparent="True">
<Image InputTransparent="True"
Aspect="AspectFill"
Source="demoperson.jpg"/>
<Grid RowDefinitions="40"
ColumnDefinitions="*"
RowSpacing="8"
HorizontalOptions="Fill"
VerticalOptions="FillAndExpand"
Padding="15"
>
<VerticalStackLayout Grid.Row="0">
<Label Text="Demo" FontSize="60" FontAttributes="Bold" VerticalOptions="Center" HorizontalOptions="FillAndExpand" HorizontalTextAlignment="Center" TextColor="White"></Label>
<Label Text="Adding life to people" FontSize="20" FontAttributes="Bold" VerticalOptions="Center" HorizontalOptions="FillAndExpand" HorizontalTextAlignment="Center" TextColor="White"></Label>
</VerticalStackLayout>
</Grid>
</Grid>
</Shell.FlyoutHeader>
<FlyoutItem Title="Clicking Me Doesnt Work"
FlyoutIcon="{StaticResource IconBluetoothLE}">
<ShellContent ContentTemplate="{DataTemplate pages:HomePage}"
Route="HomePage" >
</ShellContent>
</FlyoutItem>
<FlyoutItem Title="Session"
FlyoutIcon="{StaticResource IconHeartRate}">
<ShellContent ContentTemplate="{DataTemplate pages:HeartRatePage}"
Route="HeartRatePage">
</ShellContent>
</FlyoutItem>
<FlyoutItem Title="User Management"
FlyoutIcon="{StaticResource IconUser}">
<ShellContent ContentTemplate="{DataTemplate pages:EndUserList}"
Route="EndUserList" >
</ShellContent>
</FlyoutItem>
<FlyoutItem Title="Settings"
FlyoutIcon="{StaticResource IconGears}">
<ShellContent ContentTemplate="{DataTemplate pages:SettingsPage}"
Route="SettingsPage">
</ShellContent>
</FlyoutItem>
<Shell.FlyoutFooter>
<VerticalStackLayout>
<Label Text="© DEMO 2023" FontSize="Small" VerticalOptions="Center" HorizontalOptions="Center" HorizontalTextAlignment="Center" TextColor="Black"></Label>
</VerticalStackLayout>
</Shell.FlyoutFooter>
</Shell>
Steps to Reproduce
- create new maui app
- use the Appshell.xaml from above to simulate issue)
- Run the app and on IOS the first menu item is not clickable
Link to public reproduction project repository
No response
Version with bug
Is this a regression from previous behavior?
Yes, this used to work in .NET MAUI
Last version that worked well
Affected platforms
iOS
Affected platform versions
16.6
Did you find any workaround?
https://github.com/dotnet/maui/issues/17965#issuecomment-1763354239
Relevant log output
No response
About this issue
- Original URL
- State: open
- Created 9 months ago
- Reactions: 9
- Comments: 24 (4 by maintainers)
Commits related to this issue
- [iOS] Fix Flyout Header breaking clicking over items The Flyout Header height was being defined as `ArrangedHeaderViewHeightWithNoMargin` + `HeaderTopMargin`, but the `HeaderView.MeasuredHeight` (val... — committed to dotnet/maui by emaf 7 months ago
- [iOS] Fix Flyout Header breaking clicking over items The Flyout Header height was being defined as `ArrangedHeaderViewHeightWithNoMargin` + `HeaderTopMargin`, but the `HeaderView.MeasuredHeight` (val... — committed to dotnet/maui by emaf 7 months ago
- Progress on iOS layout https://github.com/dotnet/maui/issues/17965 — committed to FHU/Priorities by kenancasey 7 months ago
- [iOS] Fix Flyout Header breaking clicking over items The Flyout Header height was being defined as `ArrangedHeaderViewHeightWithNoMargin` + `HeaderTopMargin`, but the `HeaderView.MeasuredHeight` (val... — committed to dotnet/maui by emaf 7 months ago
- [iOS] Fix Flyout Header breaking clicking over items The Flyout Header height was being defined as `ArrangedHeaderViewHeightWithNoMargin` + `HeaderTopMargin`, but the `HeaderView.MeasuredHeight` (val... — committed to dotnet/maui by emaf 7 months ago
- [iOS] Fix Flyout Header breaking clicking over items The Flyout Header height was being defined as `ArrangedHeaderViewHeightWithNoMargin` + `HeaderTopMargin`, but the `HeaderView.MeasuredHeight` (val... — committed to dotnet/maui by emaf 7 months ago
- [iOS] Fix Flyout Header breaking clicking over items The Flyout Header height was being defined as `ArrangedHeaderViewHeightWithNoMargin` + `HeaderTopMargin`, but the `HeaderView.MeasuredHeight` (val... — committed to dotnet/maui by emaf 7 months ago
- [iOS] Fix Flyout Header breaking clicking over items The Flyout Header height was being defined as `ArrangedHeaderViewHeightWithNoMargin` + `HeaderTopMargin`, but the `HeaderView.MeasuredHeight` (val... — committed to dotnet/maui by emaf 7 months ago
- [iOS] Fix Flyout Header breaking clicking over items The Flyout Header height was being defined as `ArrangedHeaderViewHeightWithNoMargin` + `HeaderTopMargin`, but the `HeaderView.MeasuredHeight` (val... — committed to dotnet/maui by emaf 7 months ago
- [iOS] Fix Flyout Header breaking clicking over items The Flyout Header height was being defined as `ArrangedHeaderViewHeightWithNoMargin` + `HeaderTopMargin`, but the `HeaderView.MeasuredHeight` (val... — committed to dotnet/maui by emaf 7 months ago
the issue already exists, but here i have found a workaround:
You’re awesome!! Thank you so much for doing this research. We’ll get started on the fix and plan to have it ready by GA or SR1, depending on the risk of the change.
I’m experiencing this issue also:
https://github.com/biozal/dotnet-cblite-inventory/blob/main/src/Dotnet.Cblite.Inventory.Maui/AppShell.xaml
iOS Specifically the first menu item isn’t clickable. This is on an iPhone 13 Mini simulator specifically.
The workaround provided by @jcsnider did not work for me. It seems that the first item is not tappable regardless, so my workaround is to add a dummy item at the top of the list:
<ShellContent Title="-" Route="topGoesNowhere" ContentTemplate="{DataTemplate local:HomePage}" IsVisible="{OnPlatform iOS=true, Android=false}" > </ShellContent>With this I can now tap the top item.
EDIT: Since this issue is not affecting all of my iOS devices, it has caused an issue for those that CAN tap the first item. Will have to workaround this as well by redirecting to the correct route.
EDIT 2: Workaround for issue with iOS device that IS tappable on the first item, is to listen for route
topGoesNowherein OnNavigating and executing e.Cancel().I’m on .NET 8 GA and having this issue. On a larger Plus size screen it works OK, but on a smaller Pro screen the issue persists.
So another option… is to add a margin property to the top level view inside the header (in our case the grid) and also set a minimumheightrequest property that is a bit bigger than the heightrequest property on ios.
I added the following in my AppShell constructor.
The above makes my flyout work nearly perfectly. Afterwards the only issue the white horizontal bar above my header… maybe a ios safe area thing? Either way I can live with it until a proper fix is released. Tested and working on an iPhone 8 simulator and a iPhone 14 Pro Max (very different sizes).
I just tested every .Net 8 preview until I found one with a different behavior…
In 8.0.0-preview.1.7762 and 8.0.0-preview.2.7871 there was a spacing issue between the header and the flyout menu items (ref #11679). There was a large gap between the header and the items but the items were all able to be interacted with. That visual spacing issue was fixed by PureWeen in #12480 and merged into 8.0.0-preview.3.8149.
Since 8.0.0-preview.3.8149 this issue has existed where the items are placed properly but the area that we can tap/interact with still seems to be blocked. I am not sure if related to #12480 but I think it’s likely. Furthermore, It’s not always the first item that can’t be tapped, it can be the first and second based on device screen size and item size.