From 75feec40ec10c95dcd9e281343985e0ca777e573 Mon Sep 17 00:00:00 2001 From: lawvs <18554747+lawvs@users.noreply.github.com> Date: Tue, 6 Aug 2024 19:56:20 +0800 Subject: [PATCH] chore: update data input view to handle empty values --- .changeset/nice-deers-roll.md | 7 +++++++ packages/filter/src/views/data-input-views.tsx | 4 ++++ 2 files changed, 11 insertions(+) create mode 100644 .changeset/nice-deers-roll.md diff --git a/.changeset/nice-deers-roll.md b/.changeset/nice-deers-roll.md new file mode 100644 index 0000000..01f6e54 --- /dev/null +++ b/.changeset/nice-deers-roll.md @@ -0,0 +1,7 @@ +--- +"@fn-sphere/filter": patch +--- + +Update data input view to handle empty values + +If input value is empty string, the input view will update the rule args to `[]` instead of `[""]`. This is to prevent the rule from running with an empty string as an argument. diff --git a/packages/filter/src/views/data-input-views.tsx b/packages/filter/src/views/data-input-views.tsx index 28febae..d1e9eae 100644 --- a/packages/filter/src/views/data-input-views.tsx +++ b/packages/filter/src/views/data-input-views.tsx @@ -26,6 +26,10 @@ export const presetDataInputSpecs: DataInputViewSpec[] = [ type="text" value={(rule.args?.[0] as string) ?? ""} onChange={(value) => { + if (!value.length) { + updateInput([]); + return; + } updateInput([value]); return; }}