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

DateInput: Fix type of value props #1260

Conversation

wildtangent
Copy link
Contributor

@wildtangent wildtangent commented Jan 14, 2025

The DateInput component types for the value and defaultValue prop expect to be both the default type for the InputHTMLAttributes<HTMLInputElement>, e.g. string | string[] | undefined but ALSO a DateInputValue which expects an object of. { day: string, month: string, year: string }

It is not possible for the value to be both a string and an object!

This fix allows the value and defaultValue to be set as a DateInputValue only by using Omit to exclude the default types from the HTMLInputElement type, in the same way that label was omitted.

This change allows the DateInput component to work properly with react-hook-form which passes the value into the component via the register function and onChange functions.

Copy link
Owner

@daniel-ac-martin daniel-ac-martin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@wildtangent wildtangent marked this pull request as ready for review January 15, 2025 14:48
@daniel-ac-martin
Copy link
Owner

@wildtangent: Looks good. Before I merge though, can I confirm that this is Crown Copyright? (Or that you are able to assign it to the Crown.)

@daniel-ac-martin daniel-ac-martin changed the title bug: update typing on DateInput component to Omit the value and defaultValue DateInput: Fix type of value props Jan 15, 2025
@wildtangent
Copy link
Contributor Author

@wildtangent: Looks good. Before I merge though, can I confirm that this is Crown Copyright? (Or that you are able to assign it to the Crown.)

Per our discussion, I can confirm that the code would be under Crown Copyright. 👍 👑

@daniel-ac-martin daniel-ac-martin merged commit 9a2db88 into daniel-ac-martin:master Jan 21, 2025
22 checks passed
@daniel-ac-martin
Copy link
Owner

Thanks @wildtangent.

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.

2 participants