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

feat(dropdown): auto and array support in placement #1814

Closed

Conversation

mschoudry
Copy link
Contributor

Added support for auto placement and array can be defined inside placement attribute of dropdown.

const dropDownEle = getDropdownEl(compiled);

expect(dropDownEle).toHaveCssClass('dropdown');
expect(dropDownEle.getAttribute('ng-reflect-placement')).toEqual('auto');

Choose a reason for hiding this comment

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

We should not use ng-reflect- attributes in tests as it is impl-specific and can change at any moment (not to mention the fact that it is not there in production mode).

TBH I'm not sure what you are trying to assert with this test so it is hard for me to suggest changes...

const dropDownEle = getDropdownEl(compiled);

expect(dropDownEle).toHaveCssClass('dropdown');
expect(dropDownEle.getAttribute('ng-reflect-placement')).toEqual('left-top,top-left,auto');

Choose a reason for hiding this comment

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

Same comment as above...


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

Choose a reason for hiding this comment

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

Why not PlacementArray?

Choose a reason for hiding this comment

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

Oh, I see, sorry for the noise.

@@ -102,9 +108,17 @@ export class NgbDropdown {
this._zoneSubscription = ngZone.onStable.subscribe(() => { this._positionMenu(); });
}

isUp() { return this.placement.indexOf('top') !== -1; }
isUp() {

Choose a reason for hiding this comment

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

Maybe we should simplify those methods in the following way:

  • isDown() is true only when there is bottom somewhere in placement
  • isUp() = !isDown()

WDYT?

In any case we should tests for this logic.

@jbistis
Copy link

jbistis commented Jan 21, 2018

Is there a fix for this?

@suhailkc
Copy link

Is there any fix for this ???

@mikelhamer
Copy link

A fix would be awesome :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants