Skip to content

Commit

Permalink
fix(core): Dropdown fix max height (#6748)
Browse files Browse the repository at this point in the history
  • Loading branch information
vladimirpotekhin authored Feb 12, 2024
1 parent db83218 commit c4c43d1
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions projects/core/directives/dropdown/dropdown.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ export class TuiDropdownComponent {
private update(top: number, left: number): void {
const {style} = this.el.nativeElement;
const {right} = this.el.nativeElement.getBoundingClientRect();
const {maxHeight, offset} = this.options;
const {maxHeight, minHeight, offset} = this.options;
const {innerHeight} = this.win;
const clientRect = this.el.nativeElement.offsetParent?.getBoundingClientRect();
const {position} = this.directive;
Expand All @@ -116,10 +116,14 @@ export class TuiDropdownComponent {
? rect.top - 2 * offset
: offsetY + innerHeight - top - offset;

const sided = right <= rect.left || left >= rect.right;

style.position = position;
style.top = tuiPx(Math.max(top, offsetY + offset));
style.left = tuiPx(left);
style.maxHeight = tuiPx(Math.min(maxHeight, available));
style.maxHeight = sided
? `min(100%, ${maxHeight}px)`
: tuiPx(Math.min(maxHeight, Math.max(available, minHeight)));
style.width = '';
style.minWidth = '';

Expand Down

0 comments on commit c4c43d1

Please sign in to comment.