Skip to content

bug(MatCalendar): updating dateClass does not update calendar view #28737

Open
@digaus

Description

@digaus

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

We have displayed a calendar and when changing the month we load data from the backend to highlight certain cells.

We tried to update the dateClass using observables together with the async pipe which did not work since the calendar is not updating when the reference changes.

A workaround was to call setLocale of the date adapter which triggers a rerender.

I consider this a bug and not a feature because it is not mentioned anywhere that this cannot be done and dateFilter also can be updated asynchronously.

Reproduction

StackBlitz link:
Steps to reproduce:
1.
2.

Expected Behavior

Update calendar view on dateClass change

Actual Behavior

calendar view does not update when dateClass changes.

Environment

  • Angular: 17.3.0
  • CDK/Material: 17.3.0
  • Browser(s): Chrome
  • Operating System (e.g. Windows, macOS, Ubuntu): MacOS

Activity

mmalerba

mmalerba commented on Mar 19, 2024

@mmalerba
Contributor

It looks like the classes are calculated when the cell is first created and never updated if the function changes later: https://github.com/angular/components/blob/main/src/material/datepicker/month-view.ts#L533-L545, so this does indeed feel like a bug

added
P4A relatively minor issue that is not relevant to core functions
and removed
needs triageThis issue needs to be triaged by the team
on Mar 19, 2024
keatkeat87

keatkeat87 commented on Sep 13, 2024

@keatkeat87

yes, it should work like MatCalendar.dateFilter.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P4A relatively minor issue that is not relevant to core functionsarea: material/datepicker

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @keatkeat87@mmalerba@digaus

        Issue actions

          bug(MatCalendar): updating dateClass does not update calendar view · Issue #28737 · angular/components