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

Span TapGesture on Label FormattedString #21284

Closed
jshaffermanLT opened this issue Mar 18, 2024 · 13 comments
Closed

Span TapGesture on Label FormattedString #21284

jshaffermanLT opened this issue Mar 18, 2024 · 13 comments
Labels
area-gestures Gesture types platform/iOS 🍎 s/needs-attention Issue has more information and needs another look s/triaged Issue has been reviewed t/bug Something isn't working

Comments

@jshaffermanLT
Copy link

jshaffermanLT commented Mar 18, 2024

Description

I have followed the MAUI docs and when I try to run our application (NET 8 MAUI) it works fine on Android but the command is never executed on iOS.

This is the class verbatim from the MAUI docs:

public class HyperlinkSpan : Span
{
    public static readonly BindableProperty UrlProperty =
        BindableProperty.Create(nameof(Url), typeof(string), typeof(HyperlinkSpan), null);

    public string Url
    {
        get { return (string)GetValue(UrlProperty); }
        set { SetValue(UrlProperty, value); }
    }

    public HyperlinkSpan()
    {
        TextDecorations = TextDecorations.Underline;
        TextColor = Colors.Blue;
        GestureRecognizers.Add(new TapGestureRecognizer
        {
            // Launcher.OpenAsync is provided by Essentials.
            Command = new Command(async () => await Launcher.OpenAsync(Url))
        });
    }
}

This is the usage verbatim from the docs:

<Label>
            <Label.FormattedText>
                <FormattedString>
                    <Span Text="Alternatively, click " />
                    <local:HyperlinkSpan Text="here"
                                         Url="https://learn.microsoft.com/dotnet/" />
                    <Span Text=" to view .NET documentation." />
                </FormattedString>
            </Label.FormattedText>
        </Label>

The command is simply never executed on iOS. It works fine on Android.

Using the MAUI docs from here: https://learn.microsoft.com/en-us/dotnet/maui/user-interface/controls/label?view=net-maui-8.0#use-formatted-text

Steps to Reproduce

  1. Create a MAUI NET 8 project
  2. Create a MAUI page
  3. Place content of page as the Label (in the description)
  4. Run on Android (works fine)
  5. Run on iOS and command is never executed

Link to public reproduction project repository

No response

Version with bug

8.0.6 SR1

Is this a regression from previous behavior?

Not sure, did not test other versions

Last version that worked well

Unknown/Other

Affected platforms

iOS

Affected platform versions

iOS 15

Did you find any workaround?

I have not been able to find a workaround. I tried to use the Tapped event instead of the command but it has the sam affect (no event propagated on iOS)

Relevant log output

No response

@jshaffermanLT jshaffermanLT added the t/bug Something isn't working label Mar 18, 2024
@jfversluis
Copy link
Member

I think this should be fixed with the release from last week. Can you confirm that you are using this version?

https://github.com/dotnet/maui/releases/tag/8.0.10

@jfversluis jfversluis added platform/iOS 🍎 s/needs-info Issue needs more info from the author labels Mar 18, 2024
@jshaffermanLT
Copy link
Author

jshaffermanLT commented Mar 18, 2024

@jfversluis I am still not seeing it work with the latest update from NET 8. I went to this link:

https://dotnet.microsoft.com/en-us/download which appears to be 8.0.3 (latest suggested).

I then updated my workloads using dotnet workload update and I checked with dotnet workloads list and this is what I am seeing:

Installed Workload Id Manifest Version Installation Source

maui 8.0.7/8.0.100 SDK 8.0.200

I am slightly confused because I would have expected to see SDK 8.203 but it does appear to be on 8.0.10

@dotnet-policy-service dotnet-policy-service bot added s/needs-attention Issue has more information and needs another look and removed s/needs-info Issue needs more info from the author labels Mar 18, 2024
@flipper09112
Copy link

@jfversluis occours in 8.0.10 version too

@PureWeen
Copy link
Member

@jfversluis occours in 8.0.10 version too

Are you testing the sample from the docs? or do you have an additional repro you can add?

@PureWeen PureWeen added s/needs-info Issue needs more info from the author area-gestures Gesture types and removed s/needs-attention Issue has more information and needs another look labels Mar 19, 2024
@dotnet-policy-service dotnet-policy-service bot added s/needs-attention Issue has more information and needs another look and removed s/needs-info Issue needs more info from the author labels Mar 19, 2024
@jshaffermanLT
Copy link
Author

@PureWeen I know it wasn't directed at me but I am using the sample from the docs

@PureWeen
Copy link
Member

I tested that sample against 8.0.10 and it worked for me

Can you please zip up your sample?

@PureWeen PureWeen added s/needs-info Issue needs more info from the author and removed s/needs-attention Issue has more information and needs another look labels Mar 19, 2024
@jshaffermanLT
Copy link
Author

jshaffermanLT commented Mar 21, 2024

@PureWeen Here is the sample project I just ran and saw that iOS doesn't respond when tapped but Android build does. I am using Rider (2023.3.4), running it on an iOS simulator (iPhone 15), and using Xcode 15.2. I did a normal scaffolded project but can't attach the sample because it's too big so I will put the code in-line here (there is only one page so this is it)

`



        <Label
            Text="Hello, World!"
            Style="{StaticResource Headline}"
            SemanticProperties.HeadingLevel="Level1" />

        <Label
            Text="Welcome to &#10;.NET Multi-platform App UI"
            Style="{StaticResource SubHeadline}"
            SemanticProperties.HeadingLevel="Level2"
            SemanticProperties.Description="Welcome to dot net Multi platform App U I" />

        <Label>
            <Label.FormattedText>
                <FormattedString>
                    <Span Text="Alternatively, click " />
                    <Span Text="here"
                          TextColor="Blue"
                          TextDecorations="Underline">
                        <Span.GestureRecognizers>
                            <TapGestureRecognizer Command="{Binding TapCommand}"
                                                  CommandParameter="https://learn.microsoft.com/dotnet/maui/" />
                        </Span.GestureRecognizers>
                    </Span>
                    <Span Text=" to view .NET MAUI documentation." />
                </FormattedString>
            </Label.FormattedText>
        </Label>
        
        <Button
            x:Name="CounterBtn"
            Text="Click me" 
            SemanticProperties.Hint="Counts the number of times you click"
            Clicked="OnCounterClicked"
            HorizontalOptions="Fill" />
    </VerticalStackLayout>
</ScrollView>
`

Code behind:

`using System.Windows.Input;

namespace SpanMauiTest;

public partial class MainPage : ContentPage
{
public ICommand TapCommand => new Command(async (url) => await Launcher.OpenAsync(url));

int count = 0;

public MainPage()
{
    InitializeComponent();

    BindingContext = this;
}

private void OnCounterClicked(object sender, EventArgs e)
{
    count++;

    if (count == 1)
        CounterBtn.Text = $"Clicked {count} time";
    else
        CounterBtn.Text = $"Clicked {count} times";

    SemanticScreenReader.Announce(CounterBtn.Text);
}

}`

If you need anything else from me, please let me know and I will get it to you ASAP. This is directly from the Label docs on for MAUI.

@dotnet-policy-service dotnet-policy-service bot added s/needs-attention Issue has more information and needs another look and removed s/needs-info Issue needs more info from the author labels Mar 21, 2024
@PureWeen
Copy link
Member

PureWeen commented Mar 22, 2024

@jshaffermanLT if you delete the bin/obj folders and zip it up or push it to github then we can make sure we're testing the same thing.

@PureWeen PureWeen added s/needs-info Issue needs more info from the author and removed s/needs-attention Issue has more information and needs another look labels Mar 22, 2024
@jshaffermanLT
Copy link
Author

SpanMauiTest.zip

Here is the sample app I am using

@dotnet-policy-service dotnet-policy-service bot added s/needs-attention Issue has more information and needs another look and removed s/needs-info Issue needs more info from the author labels Mar 22, 2024
@QianaJiao QianaJiao added s/triaged Issue has been reviewed s/try-latest-version Please try to reproduce the potential issue on the latest public version labels Mar 25, 2024
@QianaJiao
Copy link

Verified this issue with Visual Studio 17.10.0 Preview 2 (8.0.14/8.0.7). It repro on iOS platform with 8.0.7, and not repro on 8.0.14.

@jfversluis
Copy link
Member

@jshaffermanLT if I pull down your sample and change the NuGet version to 8.0.14, which is the latest release, your sample works for me.

image

Could you confirm that this is the case for you as well? If so, please close this one, thanks!

@jfversluis jfversluis added s/needs-info Issue needs more info from the author and removed s/needs-attention Issue has more information and needs another look labels Mar 25, 2024
@jshaffermanLT
Copy link
Author

@jfversluis Yes it does! Thanks for getting back with me quickly, I appreciate it. I can confirm that when I updated my nugget packages to 8.0.14 all is well in the world 😄

@dotnet-policy-service dotnet-policy-service bot added s/needs-attention Issue has more information and needs another look and removed s/needs-info Issue needs more info from the author s/try-latest-version Please try to reproduce the potential issue on the latest public version labels Mar 25, 2024
@jfversluis
Copy link
Member

Perfect, thanks for letting us know!

@github-actions github-actions bot locked and limited conversation to collaborators Apr 25, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-gestures Gesture types platform/iOS 🍎 s/needs-attention Issue has more information and needs another look s/triaged Issue has been reviewed t/bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants