@@ -917,16 +917,6 @@ class Choices {
917
917
renderLimit = config . renderChoiceLimit ;
918
918
}
919
919
920
- const groupLookup : string [ ] = [ ] ;
921
- const appendGroupInSearch = config . appendGroupInSearch && isSearching ;
922
- if ( appendGroupInSearch ) {
923
- this . _store . activeGroups . forEach ( ( group ) => {
924
- if ( group . label ) {
925
- groupLookup [ group . id ] = group . label ;
926
- }
927
- } ) ;
928
- }
929
-
930
920
if ( this . _isSelectElement ) {
931
921
const backingOptions = this . _store . activeChoices . filter ( ( choice ) => ! choice . element ) ;
932
922
if ( backingOptions . length ) {
@@ -942,7 +932,7 @@ class Choices {
942
932
) ;
943
933
944
934
let selectableChoices = this . _isSelectOneElement ;
945
- const renderChoices = ( choices : ChoiceFull [ ] , withinGroup : boolean ) : void => {
935
+ const renderChoices = ( choices : ChoiceFull [ ] , withinGroup : boolean , groupLabel ?: string ) : void => {
946
936
if ( isSearching ) {
947
937
// sortByRank is used to ensure stable sorting, as scores are non-unique
948
938
// this additionally ensures fuseOptions.sortFn is not ignored
@@ -958,13 +948,7 @@ class Choices {
958
948
choices . every ( ( choice , index ) => {
959
949
// choiceEl being empty signals the contents has probably significantly changed
960
950
const dropdownItem =
961
- choice . choiceEl ||
962
- this . _templates . choice (
963
- config ,
964
- choice ,
965
- config . itemSelectText ,
966
- appendGroupInSearch && choice . groupId ? groupLookup [ choice . groupId ] : undefined ,
967
- ) ;
951
+ choice . choiceEl || this . _templates . choice ( config , choice , config . itemSelectText , groupLabel ) ;
968
952
choice . choiceEl = dropdownItem ;
969
953
fragment . appendChild ( dropdownItem ) ;
970
954
if ( isSearching || ! choice . selected ) {
@@ -984,7 +968,7 @@ class Choices {
984
968
// If we have a placeholder choice along with groups
985
969
renderChoices (
986
970
this . _store . activeChoices . filter ( ( choice ) => choice . placeholder && ! choice . groupId ) ,
987
- false ,
971
+ false , undefined ,
988
972
) ;
989
973
}
990
974
@@ -1003,11 +987,11 @@ class Choices {
1003
987
dropdownGroup . remove ( ) ;
1004
988
fragment . appendChild ( dropdownGroup ) ;
1005
989
}
1006
- renderChoices ( groupChoices , true ) ;
990
+ renderChoices ( groupChoices , true , config . appendGroupInSearch && isSearching ? group . label : undefined ) ;
1007
991
}
1008
992
} ) ;
1009
993
} else {
1010
- renderChoices ( renderableChoices ( this . _store . activeChoices ) , false ) ;
994
+ renderChoices ( renderableChoices ( this . _store . activeChoices ) , false , undefined ) ;
1011
995
}
1012
996
}
1013
997
0 commit comments