Skip to content

Commit

Permalink
Validate max input on slider component
Browse files Browse the repository at this point in the history
  • Loading branch information
urmauur committed Jan 4, 2024
1 parent a653c58 commit e8934d0
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions web/containers/Slider/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ const SliderRightPanel: React.FC<Props> = ({

const onValueChanged = (e: number[]) => {
if (!threadId) return

updateModelParameter(threadId, name, e[0])
}

Expand Down Expand Up @@ -58,7 +57,13 @@ const SliderRightPanel: React.FC<Props> = ({
min={min}
max={max}
value={String(value)}
onChange={(e) => onValueChanged([Number(e.target.value)])}
onChange={(e) => {
if (Number(e.target.value) >= max) {
onValueChanged([Number(max)])
} else {
onValueChanged([Number(e.target.value)])
}
}}
/>
</div>
</div>
Expand Down

0 comments on commit e8934d0

Please sign in to comment.