mirror of https://github.com/grafana/grafana
Sql: Fix an issue with connection limits not updating when jsonData is updated (#83175)
parent
ed3c36bb46
commit
393b12f49f
@ -0,0 +1,34 @@ |
||||
import React from 'react'; |
||||
|
||||
import { Input } from '@grafana/ui/src/components/Input/Input'; |
||||
|
||||
type NumberInputProps = { |
||||
value: number; |
||||
defaultValue: number; |
||||
onChange: (value: number) => void; |
||||
width: number; |
||||
}; |
||||
|
||||
export function NumberInput({ value, defaultValue, onChange, width }: NumberInputProps) { |
||||
const [isEmpty, setIsEmpty] = React.useState(false); |
||||
return ( |
||||
<Input |
||||
type="number" |
||||
placeholder={String(defaultValue)} |
||||
value={isEmpty ? '' : value} |
||||
onChange={(e) => { |
||||
if (e.currentTarget.value?.trim() === '') { |
||||
setIsEmpty(true); |
||||
onChange(defaultValue); |
||||
} else { |
||||
setIsEmpty(false); |
||||
const newVal = Number(e.currentTarget.value); |
||||
if (!Number.isNaN(newVal)) { |
||||
onChange(newVal); |
||||
} |
||||
} |
||||
}} |
||||
width={width} |
||||
/> |
||||
); |
||||
} |
||||
Loading…
Reference in new issue