Skip to content

Commit

Permalink
fix(dropdown): correct dropup position with Bootstrap 4.1
Browse files Browse the repository at this point in the history
Fixes #2297

Closes #2313
  • Loading branch information
pkozlowski-opensource committed Apr 13, 2018
1 parent 4ef7e20 commit 91c166d
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
16 changes: 16 additions & 0 deletions src/dropdown/dropdown.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,22 @@ describe('ngb-dropdown', () => {
expect(getDropdownEl(compiled)).toHaveCssClass('dropdown');
});

it('should have x-placement attribute reflecting placement', () => {
const html = `
<div ngbDropdown placement="bottom-right">
<button ngbDropdownAnchor></button>
<div ngbDropdownMenu>
<a class="dropdown-item">dropDown item</a>
<a class="dropdown-item">dropDown item</a>
</div>
</div>`;

const fixture = createTestComponent(html);
const compiled = fixture.nativeElement;

expect(getMenuEl(compiled).getAttribute('x-placement')).toBe('bottom-right');
});

it('should be open initially if open expression is true', () => {
const html = `
<div ngbDropdown [open]="true">
Expand Down
6 changes: 4 additions & 2 deletions src/dropdown/dropdown.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@ import {positionElements, PlacementArray, Placement} from '../util/positioning';

/**
*/
@Directive(
{selector: '[ngbDropdownMenu]', host: {'[class.dropdown-menu]': 'true', '[class.show]': 'dropdown.isOpen()'}})
@Directive({
selector: '[ngbDropdownMenu]',
host: {'[class.dropdown-menu]': 'true', '[class.show]': 'dropdown.isOpen()', '[attr.x-placement]': 'placement'}
})
export class NgbDropdownMenu {
placement: Placement = 'bottom';
isOpen = false;
Expand Down

0 comments on commit 91c166d

Please sign in to comment.