Skip to content

Commit

Permalink
fix(dropdown): fix bottom position for dropdownlist (#4626)
Browse files Browse the repository at this point in the history
Closes to #4545
  • Loading branch information
svetoldo4444ka authored and valorkin committed Dec 12, 2018
1 parent 583068a commit 6e04b33
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
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;
});
}));
});

1 comment on commit 6e04b33

@anndyd
Copy link

@anndyd anndyd commented on 6e04b33 Apr 19, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This caused "drop up" menu item can't show.
屏幕快照 2019-04-19 下午11 13 54

Please sign in to comment.