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: popover right side arrow placement #17477

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all 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
9 changes: 3 additions & 6 deletions packages/primeng/src/popover/popover.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ import { absolutePosition, addClass, appendChild, findSingle, getOffset, isIOS,
import { OverlayService, PrimeTemplate, SharedModule } from 'primeng/api';
import { BaseComponent } from 'primeng/basecomponent';
import { ConnectedOverlayScrollHandler } from 'primeng/dom';
import { TimesIcon } from 'primeng/icons';
import { Ripple } from 'primeng/ripple';
import { Nullable, VoidListener } from 'primeng/ts-helpers';
import { ZIndexUtils } from 'primeng/utils';
import { Subscription } from 'rxjs';
Expand Down Expand Up @@ -330,13 +328,12 @@ export class Popover extends BaseComponent implements AfterContentInit, OnDestro

const containerOffset = <any>getOffset(this.container);
const targetOffset = <any>getOffset(this.target);
const borderRadius = this.document.defaultView?.getComputedStyle(this.container!).getPropertyValue('border-radius');
let arrowLeft = 0;

if (containerOffset.left < targetOffset.left) {
arrowLeft = targetOffset.left - containerOffset.left - parseFloat(borderRadius!) * 2;
const popoverArrowOffset = this.document.defaultView?.getComputedStyle(this.container!).getPropertyValue('--p-popover-arrow-offset');
const arrowLeft = targetOffset.left - containerOffset.left;
this.container?.style.setProperty('--p-popover-arrow-offset', `calc(${popoverArrowOffset} + ${arrowLeft}px)`);
}
this.container?.style.setProperty('--overlayArrowLeft', `${arrowLeft}px`);
Copy link
Contributor

Choose a reason for hiding this comment

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

Isn't this line correct and should be reinstated? --overlayArrowLeft always is defined. if (containerOffset.left >= targetOffset.left) then the property is set to 0px. Your proposed change would have the property undefined. Maybe your change has no negative impact, have you tested your change for this case?

Copy link
Author

Choose a reason for hiding this comment

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

it looks like --overlayArrowLeft is not used anymore in the code base, and that's the initial source of the bug.

With v18 and the introduction of the new theming system, --overlayArrowLeft was removed from the CSS file and we're using --p-popover-arrow-offset from the design tokens instead.

--p-popover-arrow-offset has a default value from the theme so if we don't override it here it will not be undefined


if (containerOffset.top < targetOffset.top) {
addClass(this.container, 'p-popover-flipped');
Expand Down