ng-bootstrap icon indicating copy to clipboard operation
ng-bootstrap copied to clipboard

Dropdown menu hides behind scrollbar

Open stefanzugal opened this issue 6 years ago • 3 comments

Bug description:

Under certain conditions (described below), the dropdown menu is hidden behind the scrollbar:

image

It seems that the re-positioning of the dropdown-menu does not take into account the scrollbars and hence does not re-position the menu even if it overlaps the scrollbar, src/util/positioning.ts, from line 149:

const windowWidth = window.innerWidth || html.clientWidth;

    return targetElBCR.left >= 0 && targetElBCR.top >= 0 && targetElBCR.right <= windowWidth &&
        targetElBCR.bottom <= windowHeight;

Link to minimally-working StackBlitz that reproduces the issue:

Minimally-working example with:

  • dropdown showing the described bug
  • re-positioned dropdown showing the normal behaviour

https://stackblitz.com/edit/angular-oadfwh

Versions of Angular, ng-bootstrap and Bootstrap:

Angular: 9 ng-bootstrap: 5.3.0 Bootstrap: 4.4.1

stefanzugal avatar Apr 23 '20 12:04 stefanzugal

Update and potential workaround: in our situation, we knew that the button will always be at the right bottom of the screen, so just added a priority placement (https://ng-bootstrap.github.io/#/components/dropdown/api).

stefanzugal avatar May 04 '20 07:05 stefanzugal

This issue is related to the way you html is structured. There is probably an overflow specified somewhere that lead to the visual artefact.

Possible solutions are as follow:

  • As you mentioned, you can specify a different placement.
  • Use container="body" on the dropdown to actually render the menu as a detached DOM node in the body, rendered absolutely above everything.

Hence I'll close this issue with these explanations as you finally workaround it.

benouat avatar Jun 18 '20 09:06 benouat

Thanks for the explanation and your efforts!

stefanzugal avatar Jun 18 '20 11:06 stefanzugal