Skip to content

fix(datepicker): add gap between range rows and handle rtl #18660

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

Merged
merged 1 commit into from
Mar 1, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 39 additions & 13 deletions src/material/datepicker/calendar-body.scss
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ $mat-calendar-body-cell-radius: 999px !default;
$mat-calendar-body-min-size: 7 * $mat-calendar-body-cell-min-size !default;
$mat-calendar-body-cell-content-size: 100% - $mat-calendar-body-cell-content-margin * 2 !default;

$mat-calendar-range-end-body-cell-size:
$mat-calendar-body-cell-content-size + $mat-calendar-body-cell-content-margin !default;

.mat-calendar-body {
min-width: $mat-calendar-body-min-size;
Expand Down Expand Up @@ -43,10 +45,44 @@ $mat-calendar-body-cell-content-size: 100% - $mat-calendar-body-cell-content-mar
&::before {
content: '';
position: absolute;
top: 0;
bottom: 0;
top: $mat-calendar-body-cell-content-margin;
left: 0;
right: 0;

// We want the range background to be slightly shorter than the cell so
// that there's a gap when the range goes across multiple rows.
height: $mat-calendar-body-cell-content-size;
width: 100%;
}
}

.mat-calendar-body-range-start::before {
// Since the range background isn't a perfect circle, we need to size
// and offset the start so that it aligns with the main circle.
left: $mat-calendar-body-cell-content-margin;
width: $mat-calendar-range-end-body-cell-size;
border-top-left-radius: $mat-calendar-body-cell-radius;
border-bottom-left-radius: $mat-calendar-body-cell-radius;

[dir='rtl'] & {
left: 0;
border-radius: 0;
border-top-right-radius: $mat-calendar-body-cell-radius;
border-bottom-right-radius: $mat-calendar-body-cell-radius;
}
}

.mat-calendar-body-range-end::before {
// Since the range background isn't a perfect circle, we need to
// resize the end so that it aligns with the main circle.
width: $mat-calendar-range-end-body-cell-size;
border-top-right-radius: $mat-calendar-body-cell-radius;
border-bottom-right-radius: $mat-calendar-body-cell-radius;

[dir='rtl'] & {
left: $mat-calendar-body-cell-content-margin;
border-radius: 0;
border-top-left-radius: $mat-calendar-body-cell-radius;
border-bottom-left-radius: $mat-calendar-body-cell-radius;
}
}

Expand Down Expand Up @@ -81,16 +117,6 @@ $mat-calendar-body-cell-content-size: 100% - $mat-calendar-body-cell-content-mar
}
}

.mat-calendar-body-range-start::before {
border-top-left-radius: $mat-calendar-body-cell-radius;
border-bottom-left-radius: $mat-calendar-body-cell-radius;
}

.mat-calendar-body-range-end::before {
border-top-right-radius: $mat-calendar-body-cell-radius;
border-bottom-right-radius: $mat-calendar-body-cell-radius;
}

@include cdk-high-contrast(active, off) {
.mat-datepicker-popup:not(:empty),
.mat-calendar-body-selected {
Expand Down
3 changes: 2 additions & 1 deletion src/material/datepicker/calendar-body.ts
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,8 @@ export class MatCalendarBody implements OnChanges, OnDestroy {

if (cell) {
this._ngZone.run(() => {
this._hoveredValue = cell.enabled ? cell.compareValue : -1;
this._hoveredValue =
cell.enabled && cell.compareValue !== this.startValue ? cell.compareValue : -1;
this._changeDetectorRef.markForCheck();
});
}
Expand Down