eufemia icon indicating copy to clipboard operation
eufemia copied to clipboard

feat(Forms): add `Field.DateOfBirth` for selecting date of birth

Open langz opened this issue 11 months ago • 2 comments

Thoughts:

  • We should probably have a validator, that validates that the date is a valid date, and that it's not in the future? As I assume a date of birth can't be in the future
  • Look into why Autocomplete always sets "off" for autoComplete property/attribute https://github.com/dnbexperience/eufemia/blob/main/packages/dnb-eufemia/src/components/autocomplete/Autocomplete.js#L1868 - https://github.com/dnbexperience/eufemia/pull/5022

Looking like this for now:

image

langz avatar Apr 28 '25 11:04 langz

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
eufemia ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 3, 2025 1:32pm

vercel[bot] avatar Apr 28 '25 11:04 vercel[bot]

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

codesandbox-ci[bot] avatar Apr 28 '25 11:04 codesandbox-ci[bot]

eufemia-starter

yarn add https://pkg.pr.new/dnbexperience/eufemia/@dnb/[email protected]

commit: 3d32c46

pkg-pr-new[bot] avatar Jun 25 '25 11:06 pkg-pr-new[bot]

Deploying eufemia with  Cloudflare Pages  Cloudflare Pages

Latest commit: 3d32c46
Status: ✅  Deploy successful!
Preview URL: https://0fadf990.eufemia-e25.pages.dev
Branch Preview URL: https://feat-date-of-birth.eufemia-e25.pages.dev

View logs

Day input field, which values are valid? Should just 1 be valid, or should we enforce 01?

It now auto correct during blur.

Add support for returnFormat, and dateFormat?

dateFormat is added. It does both. I don't think we should separate this for fields to avoid complexity.

Should onChange only return a value when a date is correctly entered, sort of the same as a [Field.Date](https://eufemia.dnb.no/uilib/extensions/forms/feature-fields/Date/)? But how will this affect the validator?

I think its good as it is for now.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Attributes/autocomplete#bday-month must support autocomplete. Handle browser autofill/autocomplete for the month value which is in an autocomplete.

I could not find anyway to test this. We have at least added these.

How should the validator work? I find the logic challenging complex here compared to a regular input field. Now we have 3 that sort of should "work like one".

Seems to work fine to me now.

tujoworker avatar Sep 16 '25 09:09 tujoworker

Thanks for the great commits 🤗

langz avatar Sep 16 '25 09:09 langz

:tada: This PR is included in version 10.81.0 :tada:

The release is available on:

Your semantic-release bot :package::rocket:

tujoworker avatar Sep 19 '25 10:09 tujoworker