Merge pull request #1380 from umap-project/range-step-rounding

Round range step to 1 digit
This commit is contained in:
Yohan Boniface 2023-10-26 22:56:47 +02:00 committed by GitHub
commit 9eea9f942d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

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>`
} }