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

[Android] Shell BackButtonBehavior binding Command to valid ICommand causes back button to disappear #7045

Open
rjygraham opened this issue May 11, 2022 · 8 comments
Labels
area-controls-shell Shell Navigation, Routes, Tabs, Flyout platform/android 🤖 s/needs-verification Indicates that this issue needs initial verification before further triage will happen s/triaged Issue has been reviewed t/bug Something isn't working
Milestone

Comments

@rjygraham
Copy link

Description

Binding to a valid ICommand on Shell.BackButtonBehavior causes back button to disappear on Android (maybe iOS as well, no idea on Windows since it is not currently supported).

Steps to Reproduce

  1. File -> New .NET MAUI App
  2. Create multi-page Shell App
  3. On SecondPage create BackButtonBehavior and bind Command to a valid ICommand on the BindingContext:
 <Shell.BackButtonBehavior>
      <BackButtonBehavior
          Command="{Binding BackCommand}"
          IsEnabled="True"
          IsVisible="True">
          <BackButtonBehavior.IconOverride>
              <FontImageSource FontFamily="OpenSansSemibold" Glyph="&#x2039;" />
          </BackButtonBehavior.IconOverride>
      </BackButtonBehavior>
  </Shell.BackButtonBehavior>
  1. Run the app and navigate to SecondPage
  2. Observe back button is not visible
  3. While app is still running, use Hot Reload to change the BackButtonBehavior Command binding to invalid ICommand and observe the back button appears but does nothing since binding is invalid

RC3 reproduction repo can be found here:
https://github.com/rjygraham/MauiShellNav

Reproduction video can be found here:
https://raw.githubusercontent.com/rjygraham/MauiShellNav/main/videos/BackButtonBehavior.mp4

Version with bug

Release Candidate 3 (current)

Last version that worked well

Unknown/Other

Affected platforms

Android, I was not able test on other platforms

Affected platform versions

Android 11

Did you find any workaround?

None yet

Relevant log output

No response

@rjygraham rjygraham added s/needs-verification Indicates that this issue needs initial verification before further triage will happen t/bug Something isn't working labels May 11, 2022
@Eilon Eilon added the area-controls-shell Shell Navigation, Routes, Tabs, Flyout label May 11, 2022
@XamlTest XamlTest added the s/triaged Issue has been reviewed label May 12, 2022
@v-longmin v-longmin added s/verified Verified / Reproducible Issue ready for Engineering Triage and removed s/needs-verification Indicates that this issue needs initial verification before further triage will happen labels May 12, 2022
@v-longmin
Copy link

Verified repro on Android 12.0 with VS 17.3.0 Preview 1.0 [32427.505.main]. Repro project:
MauiShellNav-main.zip

@PureWeen PureWeen added this to the 6.0-servicing milestone Jun 28, 2022
@Redth Redth modified the milestones: 6.0-servicing, Backlog Aug 30, 2022
@ghost
Copy link

ghost commented Aug 30, 2022

We've moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process.

@espenrl
Copy link
Contributor

espenrl commented Dec 16, 2022

The same happens on .NET 7 SR 1.

@mikkpaasuke
Copy link

Still an issue. This leaves some particular navigation requirements for a client of mine dead in the water.

@samhouts samhouts removed s/verified Verified / Reproducible Issue ready for Engineering Triage s/triaged Issue has been reviewed labels Apr 5, 2023
@Zhanglirong-Winnie Zhanglirong-Winnie added s/verified Verified / Reproducible Issue ready for Engineering Triage s/triaged Issue has been reviewed labels Aug 2, 2023
@Zhanglirong-Winnie
Copy link

Verified this issue with Visual Studio Enterprise 17.7.0 Preview 5.0. Can repro on android platform with sample project.
MauiShellNav-main.zip
7045

@dainius-r
Copy link

Same on .NET 8.
Anyway to work around this, because now back button behavior simply not works?
@PureWeen

@PureWeen PureWeen added s/needs-verification Indicates that this issue needs initial verification before further triage will happen and removed s/verified Verified / Reproducible Issue ready for Engineering Triage labels Dec 6, 2023
@jankalfus
Copy link

jankalfus commented Feb 1, 2024

Happens on both Android and iOS. The button is actually there, as it’s clickable, but it’s invisible.

Update:
I’ve managed to fix it in my case on iOS, the solution was to set Shell.ForegroundColor on ContentPage. Apparently, the default color was the same as the bar’s background, so the button was invisible.
image

But it’s still an issue on Android, the button is invisible, even when Shell.TitleColor is set to black:
image

Screen.Recording.2024-02-02.at.6.44.07.mov
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
             xmlns:viewModels="clr-namespace:Xpens.ViewModels"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             x:Class="Xpens.Views.AddExpensePage"
             Shell.ForegroundColor="Black"
             Shell.TabBarIsVisible="False"
             Title="Add expense"
             Shell.TitleColor="Black">
    <ContentPage.BindingContext>
        <viewModels:AddExpenseViewModel />
    </ContentPage.BindingContext>
    <Shell.BackButtonBehavior>
        <BackButtonBehavior TextOverride="My expenses" />
    </Shell.BackButtonBehavior>

@albyrock87
Copy link
Contributor

This is a workaround to fix the color:
handlers.AddHandler<Shell, PatchedShellRenderer>();

https://github.com/nalu-development/nalu/blob/main/Samples/Nalu.Maui.Sample/Platforms/Android/PatchedShellRenderer.cs

Which also explains the source of the bug.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-controls-shell Shell Navigation, Routes, Tabs, Flyout platform/android 🤖 s/needs-verification Indicates that this issue needs initial verification before further triage will happen s/triaged Issue has been reviewed t/bug Something isn't working
Projects
None yet
Development

No branches or pull requests