Skip to content

Clearing an optional Number input stores 0 instead of a missing value #9988

Open

Description

@bioinformatist

Describe the bug

Clearing an optional Number input changes the value to 0 instead of restoring an empty value. The serialized annotation then contains a numeric result with value.number: 0.

This matters for measurement workflows: an unavailable or withdrawn measurement must remain missing, while an explicitly entered zero must remain a valid number when the configuration permits it. The same distinction is needed for optional per-region measurements without removing the region itself. Downstream tracking: AI4S-YB/pineapplehub#22.

To Reproduce

  1. Use this configuration, with no default value and no required constraint:
<View>
  <Text name="text" value="$text"/>
  <Number name="measurement" toName="text"/>
</View>
  1. Import [{"text":"Sample"}] and open the task.
  2. Observe that the Number input starts empty.
  3. Type 12, select its contents and delete them.
  4. Inspect the input and the serialized annotation.

Actual result: the input displays 0, and a Number result with {"number":0} is serialized.

Expected behavior

The input returns to blank, and the optional measurement result is omitted, matching its initial missing state. Entering 0 explicitly must still preserve a zero result. For per-region controls, clearing a measurement must preserve the region and unrelated results.

Environment and evidence

  • Reproduced with the original Label Studio 1.23.2 frontend in Chromium 152 on Linux.
  • Source inspection at current develop commit c013134ad91f1cdbba3b7ac5ca3a5eacaf942884 finds the same input conversion. This is a source finding; the full develop application has not yet been run for this report.
  • The optional, no-default configuration above rules out required/default handling as the cause. The behavior also occurs without a positive minimum.

Root cause and proposed scope

Number.onChange uses +e.target.value. JavaScript converts the empty string to 0. The existing model already permits null and its existing result-update/serialization path supports absence.

An isolated 1.23.2 frontend prototype passing null for an empty string preserves blank values through serialization and reload, including per-region values while retaining region masks and other measurements. It does not establish a production backend round trip or completion of the upstream test suite.

The proposed fix is limited to empty-input normalization, with regression tests in the existing unit and integration suites. It should preserve explicit zero, negative values, validation, defaults, sliders and per-region/per-item binding; no new result format is needed.

Related work

I searched Number/empty/clear/null reports and PRs in this repository and the archived frontend repository on 2026-10-19 without finding a direct match.

Those changes are related compatibility context, not duplicate reports of clearing an optional input.

Implementation: #9989, with the focused source fix and unit/integration regression tests. Runtime CI and source-built 1.23.2 validation remain pending.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions