Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: column default_sort_order respected when resorting #26

Merged
merged 2 commits into from
Nov 21, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion reactable/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -696,6 +696,9 @@ class Column:
footer_style: CssRules | None = None
id: str | None = None

# props ----
default_sort_desc: bool = field(init=False)

# internal ----
# TODO: ideally this cannot be specified in the constructor
# it's just passed to the widget
Expand All @@ -714,6 +717,8 @@ def __post_init__(self):
aggregated=self.format.to_props(),
)

self.default_sort_desc = self.default_sort_order == "desc"

def _apply_transform(self, col_data: list[Any], transform: callable):
return [
to_hydrate_format(transform(CellInfo(val, ii, self.id)))
Expand Down Expand Up @@ -790,7 +795,9 @@ def merge(self, other: Column | None):
if other is None:
return self

field_attrs = {field.name: getattr(self, field.name) for field in fields(self)}
field_attrs = {
field.name: getattr(self, field.name) for field in fields(self) if field.init
}
return replace(other, **filter_none(field_attrs))

def to_props(self) -> dict[str, Any]:
Expand Down
Loading