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

Datepicker should auto-navigate to max date (month) if set, not to current date (month) #4899

Comments

@japatsu
Copy link

@japatsu japatsu commented Mar 6, 2020

Describe the bug

If max date is set, datepicker should "auto-navigate" to that month. Now (2020-03-06) it opens current month even if the last enabled date (and set max date) is in the past months (e.g. 2020-02-20).

Steps to reproduce the bug

  1. set :date-disabled-fn to return days from previous months
  2. set max="2020-02-20"
  3. Open the datepicker
  4. See error: current month (2020-03) is opened even though there isn't anything to select and it's past set max-date

Expected behavior

If set, datepicker should auto-navigate to max date, not to current date if it's out-of-range.

Versions

Libraries:

  • BootstrapVue: 2.6.0
  • Bootstrap: 4.4.1
  • Vue: 2.6.10

Environment:

  • Device: PC
  • OS: Windows 10 Pro
  • Browser: Chrome
  • Version: 80.0.3987.132 (Official Build) (64-bit)
@japatsu
Copy link
Author

@japatsu japatsu commented Mar 6, 2020

Optionally a separate "initial date" prop would resolve this i.e. one could give the date-picker the date (month) on which the calendar view would open (instead of current date).

@tmorehouse
Copy link
Member

@tmorehouse tmorehouse commented Mar 6, 2020

Yeah, the initial-date prop could be used to show the appropriate year/month (but not have a value selected).

And when setting the "today" date, we could clamp the value to between min and max value.

@tmorehouse tmorehouse self-assigned this Mar 6, 2020
@tmorehouse tmorehouse added this to To do in 2.7.0 via automation Mar 6, 2020
2.7.0 automation moved this from To do to Done Mar 10, 2020
jacobmllr95 added a commit that referenced this issue Mar 10, 2020
…constrain today/current month buttons between `min` and `max` (closes #4899) (#4906)

* feat(b-calendar, b-for-datepicker): add new initial-date prop (closes #4899)

* Update date.js

* Update date.spec.js

* Update date.spec.js

* Update form-datepicker.js

* Update date.js

* Update calendar.js

* Update date.js

* Update form-datepicker.js

* Update form-datepicker.js

* Update package.json

* Update package.json

* Update README.md

* Update README.md

* Update README.md

* Fix typos

Co-authored-by: Jacob Müller <jacob.mueller.elz@gmail.com>
@tmorehouse tmorehouse added the Status: Fixed / Implemented label May 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment