From 1755b01ed6c7132c08dc6fb1b73b05da4311573c Mon Sep 17 00:00:00 2001 From: wangyao <904190290@qq.com> Date: Fri, 22 Sep 2023 11:01:27 +0800 Subject: [PATCH] fixed[BUG#4174]:The 0 in the front of pvc autosizer input can not be deleted --- src/components/Inputs/UnitSlider/index.jsx | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/components/Inputs/UnitSlider/index.jsx b/src/components/Inputs/UnitSlider/index.jsx index 8bdc017b554..b15af7a8198 100644 --- a/src/components/Inputs/UnitSlider/index.jsx +++ b/src/components/Inputs/UnitSlider/index.jsx @@ -18,8 +18,9 @@ import React from 'react' import { Slider } from '@kube-design/components' - +import { cloneDeep, get } from "lodash"; export default class UnitSlider extends React.Component { + innerRef = React.createRef(); handleChange = value => { const { onChange, unit } = this.props let newValue = value @@ -31,6 +32,11 @@ export default class UnitSlider extends React.Component { render() { const { onChange, ...rest } = this.props - return + if (get(this.innerRef, 'current') && get(this.innerRef, 'current.value')) { + let result = cloneDeep(this.innerRef); + result.current.value = Number(this.innerRef.current.value) > 0 ? Number(this.innerRef.current.value) : this.innerRef.current.value; + this.innerRef = result; + }; + return } }