Skip to content

Commit f094fa7

Browse files
authored
Merge pull request #234 from cal-smith/dropdown
fix(dropdown): use dropdownButton instead of elementRef to ensure ...
2 parents bca0c4f + 1cd0003 commit f094fa7

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/dropdown/dropdown.component.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,7 @@ export class Dropdown implements OnInit, AfterContentInit, OnDestroy {
390390
*/
391391
_appendToBody() {
392392
const positionDropdown = () => {
393-
let pos = position.findAbsolute(this.elementRef.nativeElement, this.dropdownWrapper, "bottom");
393+
let pos = position.findAbsolute(this.dropdownButton.nativeElement, this.dropdownWrapper, "bottom");
394394
// add -40 to the top position to account for carbon styles
395395
pos = position.addOffset(pos, -40, 0);
396396
pos = position.addOffset(pos, window.scrollY, window.scrollX);
@@ -399,7 +399,7 @@ export class Dropdown implements OnInit, AfterContentInit, OnDestroy {
399399
this.dropdownMenu.nativeElement.style.display = "block";
400400
this.dropdownWrapper = document.createElement("div");
401401
this.dropdownWrapper.className = `dropdown ${this.elementRef.nativeElement.className}`;
402-
this.dropdownWrapper.style.width = this.elementRef.nativeElement.offsetWidth + "px";
402+
this.dropdownWrapper.style.width = this.dropdownButton.nativeElement.offsetWidth + "px";
403403
this.dropdownWrapper.style.position = "absolute";
404404
this.dropdownWrapper.appendChild(this.dropdownMenu.nativeElement);
405405
document.body.appendChild(this.dropdownWrapper);

0 commit comments

Comments
 (0)