Skip to content

Commit

Permalink
fixed[BUG#4174]:The 0 in the front of pvc autosizer input can not be …
Browse files Browse the repository at this point in the history
…deleted
  • Loading branch information
studyingwang23 committed Sep 22, 2023
1 parent 3e343cc commit 1755b01
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/components/Inputs/UnitSlider/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -31,6 +32,11 @@ export default class UnitSlider extends React.Component {

render() {
const { onChange, ...rest } = this.props
return <Slider onChange={this.handleChange} {...rest} />
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 <Slider onChange={this.handleChange} {...rest} innerRef={ this.innerRef} />
}
}

0 comments on commit 1755b01

Please sign in to comment.