Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add prop form - input form attribute #3896

Merged
merged 1 commit into from Jan 26, 2023

Conversation

Sam-Apostel
Copy link
Contributor

@Sam-Apostel Sam-Apostel commented Jan 11, 2023

The html element has a form attribute that associates the control with a form element by passing it the form id. (https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#form)

This pr adds this form prop to react-datepicker.

Why?

When relying on browser's form validation for the required attribute, the input needs to be bound to a form. Sometimes, (some of) the form's input element are not nested under the form and a developer can rely on the form prop to bind them together.

eg: Rendering a part of the form inside of a react portal. (Fullscreen, modal, ...)

This is a implemented to be compatible with the input element which eases migrations.

Other options

This is not a blocking pr since the developer can opt into using the customInput prop to pass an input element which has the form attribute.

The html <input /> element has a `form` attribute that associates the control with a form element by passing it the form id.
@codecov
Copy link

codecov bot commented Jan 11, 2023

Codecov Report

Merging #3896 (fdde92f) into master (5c1d6d9) will decrease coverage by 0.05%.
The diff coverage is n/a.

@@            Coverage Diff             @@
##           master    #3896      +/-   ##
==========================================
- Coverage   94.85%   94.79%   -0.06%     
==========================================
  Files          20       20              
  Lines        1671     1671              
  Branches      390      390              
==========================================
- Hits         1585     1584       -1     
- Misses         24       25       +1     
  Partials       62       62              
Impacted Files Coverage Δ
src/index.jsx 91.11% <ø> (ø)
src/year.jsx 95.77% <0.00%> (-1.41%) ⬇️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@martijnrusschen martijnrusschen merged commit be27eb2 into Hacker0x01:master Jan 26, 2023
p-rogas pushed a commit to p-rogas/react-datepicker that referenced this pull request Mar 22, 2023
Add prop `form` -  input form attribute
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants