CommunityToolkit / Maui

The .NET MAUI Community Toolkit is a community-created library that contains .NET MAUI Extensions, Advanced UI/UX Controls, and Behaviors to help make your life as a .NET MAUI developer easier
https://learn.microsoft.com/dotnet/communitytoolkit/maui
MIT License
2.2k stars 380 forks source link

[BUG] Snackbar on iOS #2223

Open agcavaleiro opened 1 day ago

agcavaleiro commented 1 day ago

Is there an existing issue for this?

Did you read the "Reporting a bug" section on Contributing file?

Current Behavior

When the snackbar is activated, instead of appearing at the bottom, it appears at the top, cutting off a portion of the panel.

Expected Behavior

When activated, the snackbar should be displayed at the bottom.

Steps To Reproduce

Below is the code snippet:

SnackbarOptions snackbarOptions = new SnackbarOptions();
snackbarOptions.BackgroundColor = RSColors.WarningPalette[90];
snackbarOptions.TextColor = RSColors.WarningPalette[20];
await AppBase.Current.MainPage.DisplaySnackbar("teste", null, "Fechar", null, snackbarOptions, default);

Simulator Screenshot - iPhone 15 - 2024-09-22 at 11 35 37

Link to public reproduction project repository

I don't have

Environment

- .NET MAUI CommunityToolkit: 9.0.3
- OS: iPhone 15, iOS 18
- .NET MAUI: 8.0

Anything else?

No response

agcavaleiro commented 1 day ago

I don't understand. Do you need the full code?

brminnick commented 1 day ago

Here is the information from the Reporting a bug section in our Contributing.md file:

Bug reproduction

We always request a reproduction sample, and that's not to make your life hard or anything like that... The reason of having a reproduction is to save us time to indentify and fix the bug. Create a new project; download the MCT NuGet; write UI; ViewModel; create a service; run it. As you can see it's a lot of timing consuming for us that we could spend fixing the actual issue. So PLEASE create a small reproduction project, upload it on GitHub or GitLab and paste the link in the issue.

We don't accept .zip files as reproduction samples, for security reasons. So if you send us a .zip file we will kindly ask you to upload it to GitHub or GitLab and share the link And most important: Please, help us to help you ❤️

agcavaleiro commented 1 day ago

Ok, I get it. Sorry, this is my first interaction, so I'm still learning. I found the bug, it happens in the extension:

public static Task DisplaySnackbar(this VisualElement? visualElement, string message, Action? action = null, string actionButtonText = "OK", TimeSpan? duration = null, SnackbarOptions? visualOptions = null, CancellationToken token = default(CancellationToken))
{
return Snackbar.Make(message, action, actionButtonText, duration, visualOptions, visualElement).Show(token);
}

When I used the snackbar directly passing the anchor as null, it worked perfectly.