From 53a3c199ec1f984862d2a87282b4290b6106874e Mon Sep 17 00:00:00 2001 From: Joel Date: Tue, 6 Aug 2024 15:33:38 +0800 Subject: [PATCH] chore: input slider --- .../components/input-number-with-slider.tsx | 14 +++++-- .../list-filter/components/limit-config.tsx | 40 ++++--------------- 2 files changed, 19 insertions(+), 35 deletions(-) diff --git a/web/app/components/workflow/nodes/_base/components/input-number-with-slider.tsx b/web/app/components/workflow/nodes/_base/components/input-number-with-slider.tsx index e5d9b35613..c64f98093a 100644 --- a/web/app/components/workflow/nodes/_base/components/input-number-with-slider.tsx +++ b/web/app/components/workflow/nodes/_base/components/input-number-with-slider.tsx @@ -21,9 +21,17 @@ const InputNumberWithSlider: FC = ({ onChange, }) => { const handleBlur = useCallback(() => { - if (value === undefined || value === null) + if (value === undefined || value === null) { onChange(defaultValue) - }, [defaultValue, onChange, value]) + return + } + if (max !== undefined && value > max) { + onChange(max) + return + } + if (min !== undefined && value < min) + onChange(min) + }, [defaultValue, max, min, onChange, value]) const handleChange = useCallback((e: React.ChangeEvent) => { onChange(parseFloat(e.target.value)) @@ -33,7 +41,7 @@ const InputNumberWithSlider: FC = ({
= ({ }) }, [onChange, config]) - const handleBlur = useCallback(() => { - const payload = config - if (!payload) - return - - if (payload.size === undefined || payload.size === null) - handleLimitSizeChange(LIMIT_SIZE_DEFAULT) - }, [handleLimitSizeChange, config]) - return (
= ({ > {payload?.enabled ? ( -
- handleLimitSizeChange(e.target.value)} - onBlur={handleBlur} - disabled={readonly || !payload?.enabled} - /> - -
+ ) : null}