-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
feat(dropdown): auto and array support in placement #1814
Conversation
src/dropdown/dropdown.spec.ts
Outdated
const dropDownEle = getDropdownEl(compiled); | ||
|
||
expect(dropDownEle).toHaveCssClass('dropdown'); | ||
expect(dropDownEle.getAttribute('ng-reflect-placement')).toEqual('auto'); |
There was a problem hiding this comment.
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...
src/dropdown/dropdown.spec.ts
Outdated
const dropDownEle = getDropdownEl(compiled); | ||
|
||
expect(dropDownEle).toHaveCssClass('dropdown'); | ||
expect(dropDownEle.getAttribute('ng-reflect-placement')).toEqual('left-top,top-left,auto'); |
There was a problem hiding this comment.
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'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not PlacementArray
?
There was a problem hiding this comment.
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.
src/dropdown/dropdown.ts
Outdated
@@ -102,9 +108,17 @@ export class NgbDropdown { | |||
this._zoneSubscription = ngZone.onStable.subscribe(() => { this._positionMenu(); }); | |||
} | |||
|
|||
isUp() { return this.placement.indexOf('top') !== -1; } | |||
isUp() { |
There was a problem hiding this comment.
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 isbottom
somewhere in placementisUp()
=!isDown()
WDYT?
In any case we should tests for this logic.
7ebcbbd
to
7be431b
Compare
Is there a fix for this? |
Is there any fix for this ??? |
A fix would be awesome :) |
Added support for auto placement and array can be defined inside placement attribute of dropdown.