algolia / angular-instantsearch

โšก๏ธLightning-fast search for Angular apps, by Algolia
https://algolia.com/doc/deprecated/instantsearch/angular/v4/api-reference/instantsearch/
MIT License
261 stars 73 forks source link

Refinement List Item Label Not Changing #721

Closed asithade closed 3 years ago

asithade commented 4 years ago

Describe the bug ๐Ÿ›

Unable to change the label of refinement list item using angular-instantsearch@3.0.0-beta.5

To Reproduce ๐Ÿ”

 <ais-refinement-list attribute="averageRating" searchable class="search-list-refinement"
      [transformItems]="convertToStars">
 </ais-refinement-list>
  public convertToStars(items: RefinementListItem[]): RefinementListItem[] {
    return items.map(
      (item: RefinementListItem): RefinementListItem => ({
        ...item,
        label: `Label: ${item.label}`
      })
    );
  }

https://codesandbox.io/s/awesome-proskuriakova-9hmpz

Looks like this issue is happening in other versions too.

Expected behavior ๐Ÿ’ญ

Should change the label.

Haroenv commented 4 years ago

Hi, the value used in refinementlist for now is highlighted (even when not searchable), not label, so you should transform that one as well.

https://codesandbox.io/s/amazing-aryabhata-ezedp?file=/src/app/app.component.ts:512-559

asithade commented 4 years ago

Hi, the value used in refinementlist for now is highlighted (even when not searchable), not label, so you should transform that one as well.

https://codesandbox.io/s/amazing-aryabhata-ezedp?file=/src/app/app.component.ts:512-559

If that's the case, then the type definition for RefineListItem should be updated. Currently it is set to the following:

export declare type RefinementListItem = {
    value: string;
    label: string;
    count: number;
    isRefined: boolean;
};
Haroenv commented 4 years ago

Good catch, thanks!

tkrugg commented 3 years ago

fixed now that the types come from InstantSearch.js