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

bug(COMPONENT): MatCalendar does not show initially selected date #26363

Closed
1 task
alberthaff opened this issue Jan 4, 2023 · 3 comments
Closed
1 task

bug(COMPONENT): MatCalendar does not show initially selected date #26363

alberthaff opened this issue Jan 4, 2023 · 3 comments
Labels
needs triage This issue needs to be triaged by the team

Comments

@alberthaff
Copy link

alberthaff commented Jan 4, 2023

Is this a regression?

  • Yes, this behavior used to work in the previous version

The previous version in which this bug was not present was

No response

Description

When I'm using the mat-calendar component, it doesn't show the initially selected date.
I've tried locally and modifying a StackBlitz example from the docs (see reproduction). Neither seem to work.

Reproduction

Steps to reproduce:

  1. Set an initial value for the selected input to a value that differs from today. (eg. new Date(2010,10,9)).
  2. The calendar shows today as selected.

Example: https://stackblitz.com/edit/angular-34hcys?file=src%2Fapp%2Fdatepicker-inline-calendar-example.ts

Expected Behavior

The component should show the initial value.

Actual Behavior

The component always sets the default value to today.

Environment

  • Angular: 14.2.12
  • CDK/Material: 14.2.7 / 14.2.7
  • Browser(s): Chrome 108
  • Operating System (e.g. Windows, macOS, Ubuntu): MacOS (Monterey)
@alberthaff alberthaff added the needs triage This issue needs to be triaged by the team label Jan 4, 2023
@tomicarsk6
Copy link
Contributor

tomicarsk6 commented Jan 8, 2023

You can use the option startAt to set the calendar's initial date together with the selected option. Take a look at the updated stackblitz example.

@alberthaff
Copy link
Author

I see. Thank you! 👍

@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Feb 9, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
needs triage This issue needs to be triaged by the team
Projects
None yet
Development

No branches or pull requests

2 participants