Skip to content

Characters from formatting count towards maxLength for Input fields #4312

Description

@Gunnar-Solli-Olsen

Description of the bug

Characters from formatting count towards maxLength for Input fields, this causes the count of remaining symbols to be incorrect. The following image shows an input field that should say "Du har 7 tegn igjen", it shows 0 due to formatting inserting spaces for numbers, and two punctuations.

Image

Additionally formatting characters count towards the maxlength without accounting for characters consumed by formatting, adjusting to account for maximum length causes maxLength to initially be too large.

Image

Correct behaviour would be to store input to formatted number separately from visual formatting, read maxLength from input while applying format visually.

Steps To Reproduce

  1. Make blank page in altinn studio
  2. Use input field with both formatting and maxLength

Additional Information

Code for field shown:

  {
    "id": "S08-Input-Kontonummer",
    "type": "Input",
    "textResourceBindings": {
      "title": "S08-Input-Kontonummer.Title",
      "description": "S08-Input-Kontonummer.Description"
    },
    "dataModelBindings": {
      "simpleBinding": {
        "field": "FlatData.Kontonummer",
        "dataType": "DataModel"
      }
    },
    "formatting": {
      "number": {
        "format": "####.##.#####",
        "allowLeadingZeros": true
      }
    },
    "required": true,
    "maxLength": 13
  },

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status
    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions