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 sort state field undefined error #2793

Merged
merged 2 commits into from
Nov 11, 2024
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"changes": [
{
"comment": "fix: sortState field undefined occor error\n\n",
"type": "none",
"packageName": "@visactor/vtable"
}
],
"packageName": "@visactor/vtable",
"email": "892739385@qq.com"
}
6 changes: 4 additions & 2 deletions packages/vtable/src/ListTable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1112,8 +1112,10 @@ export class ListTable extends BaseTable implements ListTableAPI {

//重复逻辑抽取updateWidthHeight
if (sort !== undefined) {
this.internalProps.sortState = this.internalProps.multipleSort ? (Array.isArray(sort) ? sort : [sort]) : sort;
this.stateManager.setSortState((this as any).sortState as SortState);
if ((!Array.isArray(sort) && isValid(sort.field)) || Array.isArray(sort)) {
this.internalProps.sortState = this.internalProps.multipleSort ? (Array.isArray(sort) ? sort : [sort]) : sort;
this.stateManager.setSortState((this as any).sortState as SortState);
}
}
if (records) {
_setRecords(this, records);
Expand Down
8 changes: 4 additions & 4 deletions packages/vtable/src/state/state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -519,15 +519,15 @@ export class StateManager {
prev.push({
field: item.field,
order: item.order,
row: column.startInTotal + this.table.internalProps.layoutMap.leftRowSeriesNumberColumnCount ?? 0,
col: column.level
row: column?.startInTotal + this.table.internalProps.layoutMap.leftRowSeriesNumberColumnCount ?? 0,
col: column?.level
} as any);
} else {
prev.push({
field: item.field,
order: item.order,
col: column.startInTotal + this.table.internalProps.layoutMap.leftRowSeriesNumberColumnCount ?? 0,
row: column.level
col: column?.startInTotal + this.table.internalProps.layoutMap.leftRowSeriesNumberColumnCount ?? 0,
row: column?.level
} as any);
}

Expand Down
Loading