[Bug]: Draw template number fields reject valid decimals (e.g. 1.2 with step 0.1) due to floating-point step check

Open Beginner friendly
#1,129 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

@Khan-Tzar is already working on this.

Since Oct 15, 2026.

  • #1130 by @Khan-Tzar — open

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
75/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
javascript
Domain
frontend

Research direction

The check lives in DrawTool_Templater.js, in getTemplateValues, in the number case, where the quotient values[t.field] / t.step is compared with parseInt of itself. Run the node one-liner from the issue to confirm which values fail, then replace the comparison with a tolerance test against the nearest integer. Done when 1.2 with step 0.1 saves, and a value that is not a multiple of the step is still rejected.

Written by the indexing model from the issue text.

Description

bug
Checked for duplicates

Yes - I've already checked

Describe the bug

When I save a Draw feature whose property template has a number field with a decimal step (e.g. step: 0.1), many valid values are rejected. Entering 1.2 and pressing Save All Changes shows:

This feature has invalid form values: 'canopy_height_m' must be a multiple of 0.1

and the feature is not saved.

The check in DrawTool_Templater.js (getTemplateValues, the number case; line ~427 on development) compares a floating-point quotient to its integer part:

values[t.field] / t.step != parseInt(values[t.field] / t.step)

In IEEE-754, 1.2 / 0.1 === 11.999999999999998, so parseInt gives 11 and the value is "not a multiple". For step: 0.1, 16 of the 50 values from 0.1 to 5.0 are rejected: 0.3, 0.6, 0.7, 1.2, 1.4, 1.9, 2.3, 2.4, 2.8, 2.9, 3.3, 3.8, 4.1, 4.3, 4.6, 4.8. step: 0.01 is affected the same way.

The user sees a validation error for a correct value and has no way to enter it.

What did you expect?

I expected any value that is a whole number of steps from 0 (to within floating-point tolerance) to be accepted. For example:

const q = values[t.field] / t.step
if (Math.abs(q - Math.round(q)) > 1e-9) invalids[t.field] = `'${t.field}' must be a multiple of ${t.step}`

(Relative to min rather than 0 may also be intended, as in HTML <input step>, but that is a separate question.)

Reproducible steps
1. Give a Draw file a template with: { "type": "number", "field": "h", "label": "Height", "min": 0, "max": 50, "step": 0.1 }
2. Draw a feature in that file and open its properties.
3. Enter 1.2 in Height and press "Save All Changes".
4. Toast: "This feature has invalid form values: 'h' must be a multiple of 0.1". Not saved.
   (1.5 or 1.0 save fine.)

# Quick check of the arithmetic:
node -e 'for(let i=1;i<=50;i++){const v=+(i/10).toFixed(1);if(v/0.1!=parseInt(v/0.1))console.log(v)}'
Environment
- MMGIS: present on `development` (5.3.15-20260825); the comparison dates from the original templates feature (#353)
- Seen on: iPad Pro 13" (2025), iOS 26.4, WKWebView; also reproducible in any browser, as it is pure arithmetic
Dominant language
JavaScript
Stars
242
Forks
86
Avg merge
2d 1h
Merged PRs (30d)
15

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from NASA-AMMOS/MMGIS

All issues in NASA-AMMOS/MMGIS

Similar issues

More JavaScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.