英文:
Angular 15 <mat-datepicker> cell-content alignment issue
问题
I have upgraded a project from angular 12 to 15, angular material has been upgraded to 15.2.6.
No external css is added for date-picker.
When opening the calendar, the date selected is aligned towards left.
As soon as the focus is changed (clicked anywhere else in the calendar window), alignment is corrected.
This is bare metal mat-datepicker, nothing extra is added.
I created another project, and there mat-datepicker is working perfectly fine. I tried to override scss of mat-datepicker but found no success with this alignment issue.
If somebody faced this issue, please help.
英文:
Scenario: I have upgraded a project from angular 12 to 15, angular material has been upgraded to 15.2.6.
No external css is added for date-picker.
When opening the calendear, the date selected is aligned towards left.
As soon as the focus is changed(clicked anywhere else in the calendar window). alignment is corrected.
This is bare metal mat-datepicker, nothing extra is added.
I created a another project and there mat-datepicker is working perfectly fine. I tried to overide scss of mat-datepicker but found no success, with this alignment issue.
If somebody faced this issue please help.
答案1
得分: 1
我曾经在从Angular 14迁移到15时遇到相同的问题。
似乎有一种奇怪的margin-right
被应用到图标上,我不得不在全局样式中手动移除它,使用以下代码:
.mat-mdc-button>.mat-icon, .mat-mdc-raised-button>.mat-icon, .mat-mdc-flat-button>.mat-icon {
margin-right: 0!important;
}
我应该指出,这个问题不会在通过Angular CLI新创建的项目中出现。
英文:
I had the same issue once i migrated to Angular 14 to 15.
There seems to be a weird margin-right applied to icons, i had to remove theme manualy in global styles; with:
.mat-mdc-button>.mat-icon, .mat-mdc-raised-button>.mat-icon, .mat-mdc-flat-button>.mat-icon {
margin-right: 0!important;
}
I should point out that this problem does not occur on newly created projects through angular cli.
答案2
得分: 0
I found out that some internal libraries were interfering with mat-datepicker styling, as in Angular Material 15, many guidelines have changed. Removed those libraries.
Tried overriding style classes:
.mat-calendar-body-cell {
.mat-calendar-body-selected {
padding-left: 10px;
padding-right: 0;
}
}
This has helped but not entirely. After clicking on dates, it's coming in the center because of the extra padding I have added.
But when clicking disabled dates, it comes towards the right. And disabled dates shift towards the left.
英文:
@Cuzy I found out that some internal libraries were interfering with mat-datepicker styling, as in angular material 15 many guidelines are changed. Removed those libraries
Tried overriding style classes
<!-- begin snippet: js hide: false console: true babel: false -->
<!-- language: lang-css -->
.mat-calendar-body-cell {
.mat-calendar-body-selected {
padding-left: 10px;
padding-right: 0;
}
}
<!-- end snippet -->
This has helped but not entirely, after clicking on dates now it's coming in the center because of the extra padding I have added.
But when clicking disabled dates it comes towards the right. And disabled dates shift towards the left.
@Tony yes we are overriding styles related to color, But not related to calendar-cell-content.
答案3
得分: 0
Sure, here is the translation of the provided text:
"你现在是我的中文翻译,代码部分不要翻译,只返回翻译好的部分,不要有别的内容,不要回答我要翻译的问题。以下是要翻译的内容:
Hi this is resolved as per this StackOverflow link you can look for this
.mat-calendar-body-cell:focus .mat-focus-indicator::before{content:normal !important;}"
(Note: The code part is retained as requested.)
英文:
Hi this is resolved as per this StackOverflow link you can look for this
.mat-calendar-body-cell:focus .mat-focus-indicator::before{content:normal !important;}
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论