gabrielguerrero / ngrx-traits

NGRX Traits is a library to help you compose and reuse state logic in your angular app. There is two versions, @ngrx-traits/signals supports ngrx-signals, and @ngrx-traits/{core, common} supports ngrx.
MIT License
44 stars 3 forks source link

if store with local sort and local filter have defaults, clearing the filter doesnt return all the items #104

Closed gabrielguerrero closed 1 week ago

gabrielguerrero commented 1 week ago

Given a store like the following with local sort and filter, and default values for each filter and sort

 const Store = signalStore(
        withEntities({
          entity,
        }),
        withCallStatus(),
        withEntitiesLocalFilter({
          entity,
          defaultFilter: { search: '' },
          filterFn: (entity, filter) =>
            !filter?.search ||
            entity?.name.toLowerCase().includes(filter?.search.toLowerCase()),
        }),
        withEntitiesLocalSort({
          entity,
          defaultSort: { field: 'name', direction: 'asc' },
        }),
      );
  The list loads with the correct filter applied, but if you clear the filter the entities list doesnt return all results, and loses the sort order

  Workaround: ensure withEntitiesLocalSort is before withEntitiesLocalFilter in the store definition
github-actions[bot] commented 1 week ago

:tada: This issue has been resolved in version 17.8.2 :tada:

The release is available on:

Your semantic-release bot :package::rocket: