Showing 1 – 1 of 1 replies
slim26

I'm building custom angular4 dropdown […]

slim26 PURCHASED
6 years ago
Hi @themicon,

I'm building custom angular4 dropdown component which needs to append it's options element for the dropdown directly into the body and it will calculate an absolute positioning of options element by taking the position of it's parent element but I've discovered that it's not working as it should due to constraints of some of the CSS classes attached to the parent container elements as ".layout-container" and ".main-container" typically it breaks because of this styles as when I remove these classes the positioning works fine:

.layout-container {
position: relative;
width: 100%;
height: 100%;
}

and

.main-container {
position: relative;
height: calc(100% - 60px);
overflow: auto;
-webkit-overflow-scrolling: touch;
}

You can replicate this issue with an example from "Append to body" section under https://valor-software.com/ngx-bootstrap/index-bs4.html#/dropdowns

Or just copy and paste the following code into your page component:

<div class="btn-group" dropdown container="body">
<button dropdownToggle type="button" class="btn btn-primary dropdownToggle">
Dropdown on Body <span class="caret"></span>
</button>
<ul *dropdownMenu class="dropdown-menu" role="menu">
<li role="menuitem"><a class="dropdown-item" href="#">Action</a></li>
<li role="menuitem"><a class="dropdown-item" href="#">Another action</a></li>
<li role="menuitem"><a class="dropdown-item" href="#">Something else here</a></li>
<li class="divider dropdown-divider"></li>
<li role="menuitem"><a class="dropdown-item" href="#">Separated link</a>
</li>
</ul>
</div>

Any suggestion would be highly appreciated as this is very desired functionality which is provided by most of third party libraries to dynamically append elements to the body.

Regards,
Anton
themicon
themicon SELLER
6 years ago
Hello Anton, we have tested the example code but couldn't replicate the same issue. Adding "container" attribute to dropdown element, appends the dropdown markup to the body and the dropdown becomes visible without problems.
The only difference we can see using "container" option is that the dropdown doesn't have the offset top because of the absolute position relative to body. Anyway, we could fix it using a translate property.
Please note that the elements mentioned, .layout-container and .main-container, are structural and core elements of the template, if you have a custom component that has conflict with this elements it could be better to try to fix the component because changing this elements will affect the entire functionality of the template.

Let us know if you have any question

Thanks
Regards