Skip to content

Commit

Permalink
feat(plugin-chart-table): table x-filtering supports single select (#…
Browse files Browse the repository at this point in the history
…1220)

* fix(plugin-chart-echarts): table support single select

* fix: remove comments
  • Loading branch information
stephenLYZ authored and zhaoyongjie committed Nov 26, 2021
1 parent 5614683 commit 631c867
Showing 1 changed file with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -234,11 +234,13 @@ export default function TableChart<D extends DataRecord = DataRecord>(

const toggleFilter = useCallback(
function toggleFilter(key: string, val: DataRecordValue) {
const updatedFilters = { ...(filters || {}) };
let updatedFilters = { ...(filters || {}) };
if (filters && isActiveFilterValue(key, val)) {
updatedFilters[key] = filters[key].filter((x: DataRecordValue) => x !== val);
updatedFilters = {};
} else {
updatedFilters[key] = [...(filters?.[key] || []), val];
updatedFilters = {
[key]: [val],
};
}
if (Array.isArray(updatedFilters[key]) && updatedFilters[key].length === 0) {
delete updatedFilters[key];
Expand Down

0 comments on commit 631c867

Please sign in to comment.