Skip to content
This repository was archived by the owner on May 24, 2024. It is now read-only.
This repository was archived by the owner on May 24, 2024. It is now read-only.

[Time Input] is allowing NaN in the hidden value field. #1495

@xenoworf

Description

@xenoworf

Bug Report

Description

If you start with an empty Time Input and enter a single digit in the 2nd or last field (e.g. minutes in hour/minute or seconds in hour/minute/second) then the component is letting the string "NaN" through.

This is a bug because NaN shouldn't be a part of even a partial iso-8601-like value, which is supposed to be what that hidden field is.

Steps to Reproduce

You can go to the component's doc page and try what I've said above. Inspect the output in your console and you'll see the NaN.

Additional Context / Screenshots

The problem is happening because parseInt(val, 10) results in NaN when val is '' (empty string).

Here is a screenshot w/ the console showing a value containing NaN:
image

Expected Behavior

Certainly not seeing NaN in the value. There are a couple behaviors we could do instead. It all depends on what behavior we want when the user enters a partial value. We DO expect the consumers to take care of end-user-input validation - so we can't try to "fix" the value in the component.

Possible Solution

@benbcai @jmsv6d @neilpfeiffer

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions