question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

required id property in DateInput, SingleDatePicker, SingleDatePickerInput

See original GitHub issue

Hi,

DateInput, SingleDatePicker and SingleDatePickerInput has id property, which is required. I cannot see why it is done as mandatory field.

Is it done on purpose or the field can be optional?

See src/components/DateInput.jsx#L7

and

        <input
          id={id}
          name={id}

Issue Analytics

  • State:open
  • Created 7 years ago
  • Comments:8 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
ljharbcommented, Feb 11, 2017

It’s done on purpose. For accessibility, all inputs must be both wrapped in a <label> that it is also linked to with id/htmlFor. IDs must be unique on the page, so a reusable component can’t safely generate them. Typically, you’d want to pass them down from the server, since that’s the only place you know for sure a component is only being used once on the page.

(also for accessibility, inputs shouldn’t be used outside of forms)

0reactions
ljharbcommented, Oct 6, 2022

Employees require a11y affordances just the same as end users - the legal requirements are often stronger for employees, in fact. The HTML standard doesn’t require a lot of things, but that’s not the authority on UI.

Read more comments on GitHub >

github_iconTop Results From Across the Web

required id property in DateInput, SingleDatePicker ... - GitHub
Hi, DateInput, SingleDatePicker and SingleDatePickerInput has id property, which is required. I cannot see why it is done as mandatory field ...
Read more >
Javascript airbnb react-dates showClearDate throwing
I have a similar issue. I get the same error "SingleDatePickerInput.js:236 Uncaught TypeError: Cannot read property 'onClearDateMouseEnter' ...
Read more >
Documentation: <amp-date-picker> - amp.dev
Provides a widget to select dates. The date picker can render as an overlay relative to input fields, or as a static calendar...
Read more >
DateInput - Grommet
Any properties to pass on to the underlying DropButton when not inline and no format. ... id. The id of the input. string....
Read more >
react-dates - CodePen
<p class="screen-reader-only" id="DateInput__screen-reader-message-date_input">Press the down arrow key to interact with the calendar and select a date.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found