Skip to content

error handling readOnly input's validity object and validationMessage #5750

@alexmeier-19

Description

@alexmeier-19

What is affected?

Component

Description

<input id="123" type="number" readOnly></input>

Default step value for this is "1". Now if you set this readOnly input in JS document.getElementById("123").value = "0.5" you'll get following:

input.reportValidity() = true
input.checkValidity() = true

BUT
input.validity Object will have "stepMismatch: true"
and
input.validationMessage = ''.
This seems to be a problem for material-web internal validation logic. It doesn't like a property of the validity object to be 'true' and an empty validationMessage at the same time.

Reproduction

create a number readOnly material web input and set its value to "0.5"

Workaround

Ensure all the inputs would be theoretically valid, although validation shouldn't be triggered in this case.

Is this a regression?

No or unsure. This never worked, or I haven't tried before.

Affected versions

1.5.0

Browser/OS/Node environment

Chrome, Windows

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