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 User: incorrect years in "Birthdate" date picker #561

Closed
ceefour opened this issue Apr 18, 2020 · 9 comments
Closed

Add User: incorrect years in "Birthdate" date picker #561

ceefour opened this issue Apr 18, 2020 · 9 comments
Assignees
Labels
bug Something isn't working

Comments

@ceefour
Copy link

ceefour commented Apr 18, 2020

Add User: incorrect years in "Birthdate" date picker

Description

The years go into the future.

Steps to reproduce

Steps to reproduce the behavior:

  1. Click Add user
  2. Click on Birthdate
  3. The earliest year selectable is 2010. I doubt if any current FusionAuth developers can fill this field ^_^

Expected behavior

Some years ago (perhaps 100 years ago?) up to this year.

Screenshots

image

Platform

(Please complete the following information)

  • Device: Web
  • OS: Ubuntu 18.04
  • Browser + version: Chrome 81

Additional context

Add any other context about the problem here.

@robotdan robotdan added the bug Something isn't working label Apr 18, 2020
@robotdan robotdan self-assigned this Apr 18, 2020
@robotdan
Copy link
Member

Bug is likely in the date picker widget.

https://github.com/inversoft/prime.js/blob/master/src/main/js/Widgets/DateTimePicker.js
https://github.com/inversoft/prime.js/blob/master/src/test/js/Widgets.DateTimePickerTest.js

If anyone wants to take a crack at it and fix it, a PR would be great.

@amans330
Copy link

@robotdan
• The expected behaviour suggests that the years should start from 100 years ago, that's okay?
• Displaying the list from 1920 might look weird, almost every time people would have to scroll down a lot. A better option would be to have years in decreasing order starting from the current year?

@robotdan
Copy link
Member

If you look at the code ( https://github.com/inversoft/prime.js/blob/7ae67b0e586e98f454750c942d1c53bc2983d59a/src/main/js/Widgets/DateTimePicker.js#L256 ) you'll see the intended behavior is to show 10 years in either direction of the current value. I would start with just fixing it so the behavior matches the intention.

@amans330
Copy link

@robotdan I think you misunderstood. I corrected the code already, now the year range would be 100 years before the current year to the current year. What I was asking is should I go for 100 years or maybe 90 or 80 years.

@ceefour
Copy link
Author

ceefour commented Dec 17, 2020

@amans330 I agree for BirthDate, years should be listed decreasing

@robotdan
Copy link
Member

@amans330 not sure I follow. Once you have the bug fixed, you can submit a PR and I can look at it, I'm sure your questions ill be clearer once I look at the code. Thanks!

@amans330
Copy link

PR --> inversoft/prime.js#25

@amans330 amans330 removed their assignment Jan 12, 2021
@robotdan
Copy link
Member

We'll be moving to an HTML 5 date picker.

@robotdan
Copy link
Member

robotdan commented Nov 17, 2022

here is a decent replacement using HTML 5 in a self service form. This just an example, but it will set the min and max age for birthdays based upon the current year.

<div class="form-row">
  [#local currentYear = .now?date?string("YYYY") /]
  [#local minYear = (currentYear?number - 120)  + "-01-01"/]
  [#local maxYear = (currentYear?number - 10) + "-01-01"/]
  <label for="${fieldId}">${label} [#if field.required] <span class="required">*</span>[/#if]</label>
  <input id="${fieldId}" type="date" name="${key}" [#if field.key = "user.birthDate"]min="${minYear}" max="${maxYear}"[/#if]/>
</div>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants