Add column sorting support to the Table component#124
Conversation
Table component
armiol
left a comment
There was a problem hiding this comment.
@Oleg-Melnik please see some minor comments.
| * @param column The column whose header content should be displayed. | ||
| * @param sortingState The current interactive sorting state of the table. | ||
| */ | ||
| // The Pointer Hover API is experimental in the current version of Compose (1.5.2). |
There was a problem hiding this comment.
Let's make it a part of the documentation section, not a standalone comment. To me it looks like an implementation note.
| * with information about headers. | ||
| * @param sortingState The current interactive sorting state of the table. | ||
| */ | ||
| // The Pointer Hover API is experimental in the current version of Compose (1.5.2). |
| /** | ||
| * Holds interactive sorting state for a [Table]. | ||
| * | ||
| * This class encapsulates sorting transitions so that the table component stays focused on |
There was a problem hiding this comment.
Let's get rid of this paragraph altogether. If you read it, you may find it really tells nothing except "this is a software component that is designed as a class in OOP-style code".
| /** | ||
| * Stores the current interactive sorting state for the table. | ||
| * | ||
| * The state is separated into a dedicated object so that sorting rules and UI interactions |
There was a problem hiding this comment.
Please kill this paragraph. It is obvious for humans. Not for agents, apparently.
dpikhulya
left a comment
There was a problem hiding this comment.
@Oleg-Melnik LGTM in general with a small potential improvement.
FYI: I've also created an issue that might be relevant in context of sorting or later if/when the table gets more column-related features: #125
| * This comparator is applied when the user has not selected a sortable header, | ||
| * if one is available. |
There was a problem hiding this comment.
Maybe it would be nice if this defaultComparator also served as a fallback sorting direction even if column sorting is active — for the cases when any column comparator interprets items as equal. In this case this would be a second-level criterion that defines item sorting in such indefinite cases.
This could practically be useful when sorting by categorical columns (e.g. statuses, etc.), in which case many rows would turn out to be "equal" according to the column's comparator alone.
If it works that way already (I didn't check it), maybe just worth documenting it here for clarity.
This PR adds column sorting support to the table component, including sortable column definitions, sorting state management, and interactive table header behavior.
Below is an example of a typical usage scenario: