taiga-family / taiga-ui

Angular UI Kit and components library for awesome people
https://taiga-ui.dev
Apache License 2.0
3.21k stars 439 forks source link

🐞 - tuiSortByChange and directionChange methods should not been called together #3915

Open xvs32x opened 1 year ago

xvs32x commented 1 year ago

Which @taiga-ui/* package(s) are the source of the bug?

addon-table

Please provide a link to a minimal reproduction of the bug

https://stackblitz.com/edit/angular-ddzbqa

Is this issue blocking you?

Non-Blocking

Description

Hi there, at first, thank you for amazing UI Library. It's the greatest!

In my application router query params and pagination are synced, so query string is a source of truth for the pagination. It looks like when a user change something on the page (sort, direction, etc...), at first, I use router to change the query string, and then, state from query string changes the pagination on a page.

When I try to change the sort column, both of methods (tuiSortByChange and directionChange) try to change query params, but Angular can't handle it. It just skips the second changing, because the previous one hasn't finished yet. Thats why we cant change the sort colum.

I'd like to change the way how it works. For example, use one event instead of two. For instance, it works the same in Angular Material (https://material.angular.io/components/sort/api#MatSort) We have only one event (sortChange) there for both - sort and direction. And it works well with query params.

Thank you!

Angular version

14.0.0

Taiga UI version

3.20.0

Which browsers have you used?

Which operating systems have you used?

loxy commented 1 week ago

Any news on this?

waterplea commented 1 week ago

Any news on this?

Not yet. Looks like we need to add a singular { sorter, direction } and { sortBy, orderBy } input-output.

loxy commented 1 week ago

Maybe we can work on this. But decision if we use your table implementation is not taken yet.

I saw that the direction comes directly from the table directive whereas the sorting is applied by tuiSortBy. Does that need to change then?

waterplea commented 6 days ago

No, table has sorter and direction and there are also "semantic" directives tuiSortBy to use key, rather than sorter and tuiDirectionOrder to do desc/asc, rather than -1/1