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(#17033): tooltip render and alignment issues in scrolltop #17792

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
13 changes: 8 additions & 5 deletions packages/primeng/src/tooltip/tooltip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -516,7 +516,7 @@ export class Tooltip extends BaseComponent implements AfterViewInit, OnDestroy {

getHostOffset() {
if (this.getOption('appendTo') === 'body' || this.getOption('appendTo') === 'target') {
let offset = this.el.nativeElement.getBoundingClientRect();
let offset = this.activeElement.getBoundingClientRect();
let targetLeft = offset.left + getWindowScrollLeft();
let targetTop = offset.top + getWindowScrollTop();

Expand All @@ -540,22 +540,25 @@ export class Tooltip extends BaseComponent implements AfterViewInit, OnDestroy {

alignLeft() {
this.preAlign('left');
const el = this.activeElement;
let offsetLeft = getOuterWidth(this.container);
let offsetTop = (getOuterHeight(this.el.nativeElement) - getOuterHeight(this.container)) / 2;
let offsetTop = (getOuterHeight(el) - getOuterHeight(this.container)) / 2;
this.alignTooltip(-offsetLeft, offsetTop);
}

alignTop() {
this.preAlign('top');
let offsetLeft = (getOuterWidth(this.el.nativeElement) - getOuterWidth(this.container)) / 2;
const el = this.activeElement;
let offsetLeft = (getOuterWidth(el) - getOuterWidth(this.container)) / 2;
let offsetTop = getOuterHeight(this.container);
this.alignTooltip(offsetLeft, -offsetTop);
}

alignBottom() {
this.preAlign('bottom');
let offsetLeft = (getOuterWidth(this.el.nativeElement) - getOuterWidth(this.container)) / 2;
let offsetTop = getOuterHeight(this.el.nativeElement);
const el = this.activeElement;
let offsetLeft = (getOuterWidth(el) - getOuterWidth(this.container)) / 2;
let offsetTop = getOuterHeight(el);
this.alignTooltip(offsetLeft, offsetTop);
}

Expand Down