Skip to content

Commit 2ff6db3

Browse files
authored
Custom date range overflowing with page level time ranges (#1499)
* fix: overflow for custom date range
1 parent 92d1558 commit 2ff6db3

File tree

2 files changed

+26
-3
lines changed

2 files changed

+26
-3
lines changed

projects/components/src/page-time-range/page-time-range.component.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,23 @@ import { ChangeDetectionStrategy, Component } from '@angular/core';
22
import { ActivatedRoute, UrlSegment } from '@angular/router';
33
import { LoggerService, NavigationService, PageTimeRangePreferenceService, TimeRange } from '@hypertrace/common';
44
import { isNil } from 'lodash-es';
5+
import { PopoverRelativePositionLocation } from '../popover/popover';
56

67
@Component({
78
selector: 'ht-page-time-range',
8-
template: ` <ht-time-range (timeRangeSelected)="this.onTimeRangeSelected($event)"></ht-time-range> `,
9+
template: `
10+
<ht-time-range
11+
[dropdownLocationPreference]="this.dropdownLocationPreference"
12+
(timeRangeSelected)="this.onTimeRangeSelected($event)"
13+
></ht-time-range>
14+
`,
915
changeDetection: ChangeDetectionStrategy.OnPush
1016
})
1117
export class PageTimeRangeComponent {
18+
public readonly dropdownLocationPreference: PopoverRelativePositionLocation[] = [
19+
PopoverRelativePositionLocation.BelowRightAligned
20+
];
21+
1222
public constructor(
1323
private readonly pageTimeRangePreferenceService: PageTimeRangePreferenceService,
1424
private readonly navigationService: NavigationService,

projects/components/src/time-range/time-range.component.ts

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ChangeDetectionStrategy, Component, EventEmitter, NgZone, Output } from '@angular/core';
1+
import { ChangeDetectionStrategy, Component, EventEmitter, Input, NgZone, Output } from '@angular/core';
22
import { IconType } from '@hypertrace/assets-library';
33
import {
44
FixedTimeRange,
@@ -12,6 +12,7 @@ import { concat, EMPTY, interval, Observable, of, timer } from 'rxjs';
1212
import { map, startWith } from 'rxjs/operators';
1313
import { ButtonRole, ButtonSize } from '../button/button';
1414
import { IconSize } from '../icon/icon-size';
15+
import { PopoverRelativePositionLocation } from '../popover/popover';
1516
import { PopoverRef } from '../popover/popover-ref';
1617

1718
@Component({
@@ -21,7 +22,11 @@ import { PopoverRef } from '../popover/popover-ref';
2122
template: `
2223
<div class="time-range" *ngIf="this.timeRange$ | async as timeRange">
2324
<div class="time-range-selector">
24-
<ht-popover (popoverOpen)="this.onPopoverOpen($event)" [closeOnNavigate]="false">
25+
<ht-popover
26+
(popoverOpen)="this.onPopoverOpen($event)"
27+
[closeOnNavigate]="false"
28+
[locationPreferences]="this.dropdownLocationPreference"
29+
>
2530
<ht-popover-trigger>
2631
<div class="trigger">
2732
<ht-icon class="trigger-icon" icon="${IconType.Calendar}" size="${IconSize.Medium}"></ht-icon>
@@ -67,6 +72,14 @@ import { PopoverRef } from '../popover/popover-ref';
6772
`
6873
})
6974
export class TimeRangeComponent {
75+
@Input()
76+
public dropdownLocationPreference: PopoverRelativePositionLocation[] = [
77+
PopoverRelativePositionLocation.BelowLeftAligned,
78+
PopoverRelativePositionLocation.BelowRightAligned,
79+
PopoverRelativePositionLocation.AboveLeftAligned,
80+
PopoverRelativePositionLocation.AboveRightAligned
81+
];
82+
7083
public timeRange$: Observable<TimeRange> = this.timeRangeService.getTimeRangeAndChanges();
7184

7285
private popoverRef: PopoverRef | undefined;

0 commit comments

Comments
 (0)