-
Notifications
You must be signed in to change notification settings - Fork 47
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
SatPopover is not honouring the popover anchor position #167
Comments
Apparently, this is the cause of this (intended or not) behavior: popover/src/lib/popover/popover.component.ts Lines 51 to 59 in 8e2915c
|
I noticed I can achieve the same effect I had with the previous versions by reassigning the popover anchor in typescript code. And I can get a reference to the popover through the anchor I'm handling (yeah, it's confusing, but take a look the snippet below), but the API, in this particular case became worse than it was. <ng-container *ngFor="let i of [1,2,3]">
<button #anchor="satPopoverAnchor"
[satPopoverAnchor]="p"
(click)="_openMenu(anchor)">Toggle</button>
</ng-container>
<sat-popover #p verticalAlign="below" hasBackdrop>
<div>
Hello!
</div>
</sat-popover> _openMenu(anchor: SatPopoverAnchor) {
anchor.popover.anchor = anchor;
anchor.popover.open();
} |
@julianobrasil just reading this. The issue you are experiencing is a known limitation of the current API (SatPopovers can only have a single anchor at a time). See this note referencing it in the original PR:
Your workaround, to dynamically reassign the anchor in code, is the right solution 👍. Edit: FWIW I think you could also accomplish the same thing in the template. i.e. <ng-container *ngFor="let i of [1,2,3]">
<button #anchor="satPopoverAnchor"
[satPopoverAnchor]="p"
(click)="p.anchor = anchor; p.open()">Toggle</button>
</ng-container>
<sat-popover #p verticalAlign="below" hasBackdrop>
<div>
Hello!
</div>
</sat-popover> But handling this in typescript is generally clearer. |
@thefliik, thanks for your answer. I hope we get back any |
In the previous version of
SatPopover
, there was this method:SatPopoverAnchor.openPopover()
. When called, this method opened the popover wherever the anchor was.Now, as there is no
openPopover()/closePopover()
anymore, I tried to achieve the same effect withSatPopoverAnchor.popover.open()
, but when we have a bunch of anchors inside a*ngFor
, for example, the popover is always anchored to the last element (I think that was the reason for having theopenPopover()/closePopover()
methods inSatPopoverAnchor
class in the previous version):You can try it here: https://stackblitz.com/edit/ncstate-sat-popover-issues-xxiynn?file=app/app.component.html
Is there another way to do what I want to? I cannot upgrade
SatPopover
to the last version without this feature.The text was updated successfully, but these errors were encountered: