react / react/react

React should recognize the `valueAsDate` property on DOM elements

Open
#11,369 18 comments 36 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Component: DOM Type: Feature Request
Dominant language
JavaScript
Stars
251k
Forks
51.4k
Avg merge
2d 4h
Merged PRs (30d)
53

Description

The valueAsDate property on the ES6 definition of HTMLInputElement is not yet recognized by React. It should be, though.

The valueAsDate property relieves the pain of having to deal with both browsers that support HTML5 date inputs and those who don't; the former require the value property to be of the form "YYYY-MM-DD" and the latter require a nicely formatted date (e.g. "MM/DD/YYYY") since the user will see exactly that. (React won't even allow that in conjunction with type="date", though, and proclaim that the machine readable format should be used.)
The browsers that do support HTML5 date input (should) alternatively support the date being passed in through the valueAsDate property. If we use that, we can always put a nicely formatted date in the value property. Pain relieved! (And also React should allow any format in the value property in that case.)

As indicated above, browser support is still lacky at best, even with the most avant garde browsers. Hence this is not an urgent issue for React. It will get relevant, though, and is herein duly noted.

Contributor guide

Open the contributing guide

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.

Research direction

The issue identifies HTMLInputElement, valueAsDate, value, and type="date" as the relevant entry points. First verify current behavior across browsers and React's handling of these properties; done means valueAsDate is recognized and the stated value-format restriction is resolved without breaking unsupported browsers.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, react
Domain
frontend, web-dev
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.