Skip to content

Commit

Permalink
fix sonarqube bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
razvanMiu committed Nov 11, 2024
1 parent e354df7 commit 8f72687
Showing 1 changed file with 17 additions and 10 deletions.
27 changes: 17 additions & 10 deletions src/Widgets/Slider.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,11 @@ export class Slider extends Component {
this.setValue(val, triggeredByUser, i);
positions[i] = this.determinePosition(val);
});
this.setState({
position: positions,
this.setState((prevState) => {
const positions = [...prevState.position];
return {
position: positions,
};
});
} else {
this.setValue(value, triggeredByUser);
Expand Down Expand Up @@ -211,11 +214,13 @@ export class Slider extends Component {

setValuePosition(value, triggeredByUser, knobIndex) {
if (this.props.multiple) {
const positions = [...this.state.position];
positions[knobIndex] = this.determinePosition(value);
this.setValue(value, triggeredByUser, knobIndex);
this.setState({
position: positions,
this.setState((prevState) => {
const positions = [...prevState.position];
positions[knobIndex] = this.determinePosition(value);
return {
position: positions,
};
});
} else {
this.setValue(value, triggeredByUser);
Expand All @@ -227,10 +232,12 @@ export class Slider extends Component {

setPosition(position, knobIndex) {
if (this.props.multiple) {
const newPosition = [...this.state.position];
newPosition[knobIndex] = position;
this.setState({
position: newPosition,
this.setState((prevState) => {
const newPosition = [...prevState.position];
newPosition[knobIndex] = position;
return {
position: newPosition,
};
});
} else {
this.setState({
Expand Down

0 comments on commit 8f72687

Please sign in to comment.