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(ui5-popup): position arrows correctly #2917

Merged
merged 3 commits into from
Mar 12, 2021
Merged

fix(ui5-popup): position arrows correctly #2917

merged 3 commits into from
Mar 12, 2021

Conversation

georgimkv
Copy link
Contributor

When the Popover is aligned horizontally against the opener,
but it is wider than the opener, the arrows will be centered to the middle of the opener element.

Fixes: #2758
Fixes: #2401

@georgimkv georgimkv requested review from ilhan007 and a team March 8, 2021 06:14
const arrowXCentered = this.horizontalAlign === PopoverHorizontalAlign.Center || this.horizontalAlign === PopoverHorizontalAlign.Stretch;
const arrowTranslateX = isVertical && arrowXCentered ? targetRect.left + targetRect.width / 2 - left - popoverSize.width / 2 : 0;
const arrowTranslateY = !isVertical ? targetRect.top + targetRect.height / 2 - top - popoverSize.height / 2 : 0;
let arrowXCentered = (this.horizontalAlign === PopoverHorizontalAlign.Center || this.horizontalAlign === PopoverHorizontalAlign.Stretch);
Copy link
Member

@ilhan007 ilhan007 Mar 11, 2021

Choose a reason for hiding this comment

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

The calcPlacement method start becoming really large, I can hardly see where it starts, could you at least extract the newly added logic as separate method somehow.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I extracted the logic for calculating the arrow in a seperate function.

When the Popover is aligned horizontally against the opener,
but it is wider than the opener, the arrows will be centered to the middle of the opener element.

Fixes: #2758
Fixes: #2401
@georgimkv georgimkv requested review from ilhan007 and a team March 12, 2021 09:43
@ilhan007 ilhan007 merged commit 5ffbbd9 into SAP:master Mar 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants