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

groupBy shows group name but doesn't group results #859

Open
LouNik1984 opened this issue Oct 2, 2024 · 2 comments
Open

groupBy shows group name but doesn't group results #859

LouNik1984 opened this issue Oct 2, 2024 · 2 comments

Comments

@LouNik1984
Copy link

LouNik1984 commented Oct 2, 2024

I'm testing the groupBy option with the demo provided. The demo array "teams" is structured so to have all the items from the first category first, and then lists all the item from the second category:

   var nhlTeams = ['Anaheim Ducks', 'Atlanta Thrashers', 'Boston Bruins', ...];
   var nbaTeams = ['Atlanta Hawks', 'Boston Celtics', 'Charlotte Bobcats', ...];
   var nhl = $.map(nhlTeams, function (team) { return { value: team, data: { category: 'NHL' }}; });
   var nba = $.map(nbaTeams, function (team) { return { value: team, data: { category: 'NBA' } }; });
   var teams = nhl.concat(nba);

This way, when we perform a search using the groupBy option, the search results shows first all the results from the first category, then all the results from the second category. In this way, the results from the same category are grouped together:

Screenshot 2024-10-02 alle 12 15 58

If we shuffle the teams items in the array so that final results from both categories are mixed:

searchquery = "bl";

var teamsddd = [
        {"value": "Anaheim Ducks", "data": {"category": "NHL"}},
        {"value": "Portland Trail Blazers", "data": {"category": "NBA"}}, // this will show in search with category NBA
        {"value": "Atlanta Thrashers", "data": {"category": "NHL"}},
        {"value": "Chicago Blackhawks", "data": {"category": "NHL"}}, // this will show in search with category NHL
        {"value": "Boston BlCeltics", "data": {"category": "NBA"}}, // this will show in search with category NBA
        {"value": "Columbus Blue Jackets", "data": {"category": "NHL"}}, // this will show in search with category NHL
        {"value": "Detroit Red Wings", "data": {"category": "NHL"}},
        {"value": "Atlanta Hawks", "data": {"category": "NBA"}},
        {"value": "Cleveland Cavaliers", "data": {"category": "NBA"}},
        {"value": "Dallas Mavericks", "data": {"category": "NBA"}},
    ];

I expect to still see the results grouped by their categories, so I expect to see the first category with its two entries, and then the second category with the other two entries, no matter where they are in the array:

NBA
- portland trail blazers // array position 2
- boston Blceltics  // array position 5
NHL
- chicago blackhawks  // array position 4
- columbus blue jackets  // array position 6

What I get, instead, is the four items of the array in the order that are listed in the array:

Screenshot 2024-10-02 alle 12 19 49

Basically, the grouping gets lost. Is this intended behaviour? To me, a groupBy option means that results should be grouped under that category depsite their original position in the array

@tkirda
Copy link
Member

tkirda commented Oct 3, 2024

@LouNik1984 you are correct. This is a bug. Do you want to create a PR with the fix?

@LouNik1984
Copy link
Author

@tkirda

Hi

I don't have a fix ready. If somebody can look into it and provide a PR with the fix, it would be great

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants