Skip to content

NGX-Bootstrap v5.6.1 Dropdown Menu append to body not aligning with the dropdown trigger element #5906

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

Open
garishsamuel opened this issue Aug 18, 2020 · 5 comments

Comments

@garishsamuel
Copy link

Bug description:

When using [container]="body" for the Dropdown component the dropdown panel is not aligned properly with the parent(trigger) element.

Plunker/StackBlitz that reproduces the issue:

This issue is easily replicated in the ngx-bootstrap demo site.

https://valor-software.com/ngx-bootstrap/#/dropdowns

image

Versions of ngx-bootstrap, Angular, and Bootstrap:

ngx-bootstrap: 5.6.1

Angular: 9.1.4

Bootstrap: 3.4.1

Expected behavior

The dropdown panel should be aligned inline with the parent(trigger) element.

image

@garishsamuel garishsamuel changed the title Bootstrap 4 Dropdown Menu append to body not aligning with the dropdown trigger element NGX-Bootstrap v5.6.1 Dropdown Menu append to body not aligning with the dropdown trigger element Aug 27, 2020
@branko-boston
Copy link

This was working correctly in v5.5.0, and broken in v5.6.0

@szymon-baranczyk
Copy link

Yep, this issue blocked my update of Angular.

@0xphilipp
Copy link

Any plan, when this will be fixed?

@pmelisko
Copy link

pmelisko commented Feb 9, 2021

Hello, thanks for great work.

There are 2 problems:

  1. https://github.com/valor-software/ngx-bootstrap/blob/v5.6.0/src/positioning/modifiers/initData.ts

// Normalize placements that have identical main placement and variation ("right right" => "right").
const matches = placement.match(/^(left|right|top|bottom)* ?(?!\1)(left|right|top|bottom)?/); if (matches) { placement = matches[1] + (matches[2] ? ${matches[2]} : ''); }
that code should normalize values like "bottom bottom" to "bottom" etc, but this will remove "start" from "bottom start" placement which is default

if start and end are valid values, normalize regex should be like this
placement.match(/^(left|right|top|bottom|start|end)* ?(?!\1)(left|right|top|bottom|start|end)?/);
Output position from initData.ts
till version v5.5.0 -> "bottom start" is resolved as "bottom start"
from version v.5.6.0 -> "bottom start" is resolved as "bottom"

  1. second problem is in https://github.com/valor-software/ngx-bootstrap/blob/v5.6.0/src/positioning/modifiers/shift.ts
    from v5.6.0 , this code was added, which will for "bottom start" will set target.left as shifOffsets.end instead of shiftOffsets.start.

data.offsets.target = {
...target, ...{
[side]: (side === shiftVariation ? (shiftOffsets as any).start[side] : (shiftOffsets as any).end[side])
}
};

Question: are start and end valid options? these options are not mentioned in docs. If yes there is no handling for these options, if no, solution should be to change default from "bottom start" to "bottom left"

Quick fix (default behaviour):
set placement as "bottom left"

@daniel-huser
Copy link

Same issue here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants