Skip to content

Commit

Permalink
fix(core): use correct host portal viewport for dropdown position
Browse files Browse the repository at this point in the history
  • Loading branch information
splincode committed Oct 17, 2023
1 parent 0df9c86 commit 434da06
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,17 @@ export class TuiDropdownPositionDirective extends TuiPositionAccessor {
top: hostRect.top - 2 * offset - viewport.top,
bottom: viewport.bottom - hostRect.bottom - 2 * offset,
} as const;
const left =
hostRect.left + width < viewport.right - offset ? hostRect.left : right;
const position = {
top: hostRect.top - offset - height,
bottom: hostRect.bottom + offset,
right,
right: viewport.left > right ? viewport.left : right,
center:
hostRect.left + hostRect.width / 2 + width / 2 < viewport.right - offset
? hostRect.left + hostRect.width / 2 - width / 2
: right,
left: hostRect.left + width < viewport.right - offset ? hostRect.left : right,
left: viewport.left > left ? viewport.left : left,
} as const;
const better = available.top > available.bottom ? 'top' : 'bottom';

Expand Down

0 comments on commit 434da06

Please sign in to comment.