dotnet / maui

.NET MAUI is the .NET Multi-platform App UI, a framework for building native device applications spanning mobile, tablet, and desktop.
https://dot.net/maui
MIT License
22k stars 1.72k forks source link

[MAUI][.NET8] Search for a recipe with "fries" first result is not "Alpine fries". #21006

Open Zhanglirong-Winnie opened 6 months ago

Zhanglirong-Winnie commented 6 months ago

Description

Search for a recipe with "fries" first result is not "Alpine fries".

Steps to Reproduce

1.Deploy https://github.com/rachelkang/recipeSearch to Windows/Android/iOS/MacOS 2.Type "fries" into the search recipe bar. 3.Click the search button to search (hit Enter)

Actual results: “Alpine fries” was not the first result, Search results are out of order. image

Expected results: "Alpine fries" is the first results

Link to public reproduction project repository

https://github.com/rachelkang/recipeSearch

Microsoft.Maui.Controls : 8.0.10-nightly.10215+sha.ce90b585c6-azdo.9163364 .NET SDK: 8.0.100

Version with bug

8.0.10-nightly.10215

Is this a regression from previous behavior?

Not a regression, this issue also repro on 8.0.7.

Affected platforms

iOS, Android, Windows, macOS

Pastajello commented 6 months ago

There is no ordering of recipes by name whatsoever in the app so what exactly is a bug? The application displays the recipes as they come from the endpoint and are supplied to the CollectionView.

image image image
IrisClasson commented 6 months ago

@Zhanglirong-Winnie Could you explain what the expected behavior is? Looking at the code I don't see where the bug is. If the search result isn't sorted then it wont be sorted. The framework doesn't know how you want the sorting to be done and you have to decide on the sorting logic yourself. It can be done alphabetically, fuzzy search, etc.

// Pseudo code for very a simple search.
 var sortedHits = recipeData.Hits.OrderBy(hit => hit.Recipe.Label);
Zhanglirong-Winnie commented 6 months ago

@Zhanglirong-Winnie Could you explain what the expected behavior is? Looking at the code I don't see where the bug is. If the search result isn't sorted then it wont be sorted. The framework doesn't know how you want the sorting to be done and you have to decide on the sorting logic yourself. It can be done alphabetically, fuzzy search, etc.

// Pseudo code for very a simple search.
 var sortedHits = recipeData.Hits.OrderBy(hit => hit.Recipe.Label);

Hi @IrisClasson Expect as shown: "Alpine fries" is the first result image

IrisClasson commented 6 months ago

The data from the edamame API doesn't return data sorted by recipe title. You probably should remove the App key from the repository if you have a request limit for the API usage.

Screenshot 2024-03-05 at 11 23 44

I submitted a PR for your app that does a simple sort on the title. You probably want to modify that to fit the search behavior you want in your app. But it's not a MAUI bug as AFAIK. I can try to help, but let's move this conversation somewhere else so we don't add more noise :)

Screenshot 2024-03-05 at 11 31 18

Zhanglirong-Winnie commented 6 months ago

Verified this issue with Visual Studio 17.10.0 Preview 2. Can repro on any platform with sample project. https://github.com/rachelkang/recipeSearch