For my situation, the answer given by androbin was very helpful.
If in this situation (please see in the end...)
I will simply remember to do the same thing for the use case of classes.
Search for: "mat-(?!mdc) Replace with: "mat-mdc-
And after that, I noticed that only the sidenav is not updated they are still using mat-sidenav, mat-sidenav-content, etc.:
IMG side-nav-after-changed-class-name
I'm using: "@angular/material": "^16.1.4". Im not sure if this is an isolated case due to my mistakes.
I liked the last part of the question. I see it as a good discussion to be open.
Also wanted to know what is best practice for an enterprise application, should we apply the style on tags applied by material or always use CSS class name?
My answer
I like to use always CSS class names. I use this convention:
same name as the name that is given by Angular Material Team and add a modifier at the end, usually --name-of-project.
The situation
The above approach caused the second problem. After replacing only the declaration of CSS classes.
Reflection
This is not suggested by the Angular Material Team.
Internal component elements
Avoid any custom styles or overrides on internal elements within Angular Material components. The DOM structure and CSS classes applied for each component may change at any time, causing custom styles to break.
This is what I have done. But I'm not afraid, because I know enough CSS to repair custom style breaks after some changes.