Skip to content

Commit

Permalink
fix(table): fix onChange calls twice (#2042)
Browse files Browse the repository at this point in the history
Co-authored-by: maxin <maxin@growingio.com>
  • Loading branch information
nnmax and maxin committed May 25, 2022
1 parent 4bfa539 commit ce9995a
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 12 deletions.
22 changes: 11 additions & 11 deletions src/table/Title.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,19 @@ const Title = <RecordType,>(props: TitleProps<RecordType>): React.ReactElement =
const nextSortOrder = getNextSortDirection(sortDirections, sortOrder ?? null);
const changedSorterState: SortState<RecordType> = sorterState
? {
...sorterState,
sortOrder: nextSortOrder,
}
...sorterState,
sortOrder: nextSortOrder,
}
: {
sortOrder: nextSortOrder,
column,
isControlled: 'sortOrder' in column,
key: columnKey,
sortDirections,
sortPriorityOrder,
};
sortOrder: nextSortOrder,
column,
isControlled: 'sortOrder' in column,
key: columnKey,
sortDirections,
sortPriorityOrder,
};

onTriggerStateUpdate({ sorterState: updateSorterStates(changedSorterState) });
updateSorterStates(changedSorterState);
};

return (
Expand Down
10 changes: 9 additions & 1 deletion src/table/demos/sorting/Sorting.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,15 @@ export const Sorting = () => {
title: 'Address',
},
];
return <Table<DataSourceType> pagination={false} dataSource={genDataSource()} columns={columns} rowKey="id" />;
return (
<Table<DataSourceType>
pagination={false}
onChange={action('handleTableChange')}
dataSource={genDataSource()}
columns={columns}
rowKey="id"
/>
);
};

// ----------------------- Sorting -----------------------//
Expand Down

1 comment on commit ce9995a

@vercel
Copy link

@vercel vercel bot commented on ce9995a May 25, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

gio-design – ./

gio-design-git-master-growingio.vercel.app
gio-design.vercel.app
gio-design-growingio.vercel.app

Please sign in to comment.