From 9689e23cc774265140f0ff274c284eca0ae955d6 Mon Sep 17 00:00:00 2001 From: lawvs <18554747+lawvs@users.noreply.github.com> Date: Fri, 26 Jul 2024 20:23:50 +0800 Subject: [PATCH] refactor: update SelectView options value --- packages/filter/src/filter-rule/index.tsx | 13 +++++-------- packages/filter/src/specs/preset.tsx | 2 +- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/packages/filter/src/filter-rule/index.tsx b/packages/filter/src/filter-rule/index.tsx index 3860ddd..559ad2a 100644 --- a/packages/filter/src/filter-rule/index.tsx +++ b/packages/filter/src/filter-rule/index.tsx @@ -27,23 +27,20 @@ export const FilterRule = ({ rule }: FilterRuleProps) => { return (
({ - value: JSON.stringify(field.path), + value: field, label: mapFieldName(field), }))} - onChange={(pathStr) => { + onChange={(newField) => { updateRule({ ...rule, // Clear filter name when field changed name: undefined, + // name: newField.filterList[0].name, // Reset arguments when field changed arguments: [], - path: JSON.parse(pathStr), + path: newField.path, }); }} /> diff --git a/packages/filter/src/specs/preset.tsx b/packages/filter/src/specs/preset.tsx index 4116498..73ca17c 100644 --- a/packages/filter/src/specs/preset.tsx +++ b/packages/filter/src/specs/preset.tsx @@ -139,7 +139,7 @@ const SelectView = ({ ); return ( - + {options.map(({ label }, index) => ( {label}