Round range step to 1 digit

This commit is contained in:
Yohan Boniface 2023-10-26 22:38:41 +02:00
parent 45c1d1c419
commit bacf8922c8

View file

@ -856,7 +856,7 @@ L.FormBuilder.Range = L.FormBuilder.FloatInput.extend({
this.input.setAttribute('list', datalist.id) this.input.setAttribute('list', datalist.id)
let options = '' let options = ''
const step = this.options.step || 1, const step = this.options.step || 1,
digits = step < 1 ? 2 : 0 digits = step < 1 ? 1 : 0
for (let i = this.options.min; i <= this.options.max; i += this.options.step) { for (let i = this.options.min; i <= this.options.max; i += this.options.step) {
options += `<option value="${i.toFixed(digits)}" label="${i.toFixed(digits)}"></option>` options += `<option value="${i.toFixed(digits)}" label="${i.toFixed(digits)}"></option>`
} }