Skip to content
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

fix(dropdown): fix bottom position for dropdownlist #4626

Merged
merged 4 commits into from Dec 12, 2018
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/dropdown/bs-dropdown.directive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -358,13 +358,19 @@ export class BsDropdownDirective implements OnInit, OnDestroy {
'transform',
this.dropup ? 'translateY(-101%)' : 'translateY(0)'
);
this._renderer.setStyle(
this._inlinedMenu.rootNodes[0],
'bottom',
'auto'
);
}
}

private removeDropupStyles(): void {
if (this._inlinedMenu && this._inlinedMenu.rootNodes[0]) {
this._renderer.removeStyle(this._inlinedMenu.rootNodes[0], 'top');
this._renderer.removeStyle(this._inlinedMenu.rootNodes[0], 'transform');
this._renderer.removeStyle(this._inlinedMenu.rootNodes[0], 'bottom');
}
}
}
14 changes: 8 additions & 6 deletions src/spec/bs-dropdown.directive.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class TestDropdownComponent {
isOpenChangeValue: Boolean = false;
insideClick: Boolean = false;
container: String = '';
placement: String = '';

constructor(config: BsDropdownConfig) {
Object.assign(this, config);
Expand Down Expand Up @@ -313,16 +314,17 @@ describe('Directive: Dropdown', () => {
expect(element.querySelector('[dropdown]').classList).not.toContain('open');
});

it('should open if isBs3 method return true', () => {
it('should open if isBs3 method return true', fakeAsync(() => {
context.placement = 'bottom';
const tempVal = window.__theme;
window.__theme = 'bs4';
expect(element.querySelector('[dropdown]').classList).not.toContain('open');
element.querySelector('button').click();
fixture.detectChanges();
expect(element.querySelector('[dropdown]').classList).toContain('open');
element.querySelector('button').click();
fixture.detectChanges();
expect(element.querySelector('[dropdown]').classList).not.toContain('open');
expect(element.querySelector('[dropdown]').classList).toContain('open');
expect(element.querySelector('[dropdownToggle]').getAttribute('aria-expanded')).toEqual('true');
tick();
expect(element.querySelector('[dropdown]').classList).toContain('open');
window.__theme = tempVal;
});
}));
});