ng-lightning / ng-lightning

Native Angular components & directives for Lightning Design System

Home Page:http://ng-lightning.github.io/ng-lightning/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ngl-datepicker-input "relativeYearTo" and "relativeYearFrom" should affect underlying FormControl Validator

bran22 opened this issue · comments

Summary

Hi, I noticed a bug with the relativeYearTo and relativeYearFrom inputs when used with the ngl-datepicker-input. It doesn't seem like these configuration options are applied to the underlying FormControl Validator in the way the min and max options do. This means that although the calendar prevents users from selecting a date outside the relative range, users are still able to type in a date outside the range and the Validator believes this is Valid. Can this be changed to mark the field as "Invalid" in the same way that min and max do?

Environment

  • Observed in Angular9 locally, reproduced in Angular11 at Stackblitz link below
  • ng-lightning@7.0.1
  • Chrome 88

Steps to reproduce:

See this stackblitz example: https://stackblitz.com/edit/angular-fhwnvr-swedkd?file=src/app/input.html

  1. Instantiate a ngl-datepicker-input that sets a minimum date using min, and sets a maximum date using relativeYearTo
  2. Use the input box to type in a date less than the minimum date
  3. Log out model.valid and observe it is false - This is expected behavior
  4. Use the input box to type in a date greater than the maximum date
  5. Log out model.valid and observe it is true - This unexpected, I expected it to be false as well