Repository navigation
Fix Email tooltip of the user avatar in the chat report page is incorrectly positioned #16370
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
Changes from all commits
b4ade6e
aef1196
107c607
6ba71ec
eac6c73
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -49,6 +49,33 @@ function computeHorizontalShift(windowWidth, xOffset, componentWidth, tooltipWid | |
| return 0; | ||
| } | ||
|
|
||
| /** | ||
| * Determines if there is an overlapping element at the top of a given coordinate. | ||
| * | ||
| * @param {Number} xOffset - The distance between the left edge of the window | ||
| * and the left edge of the wrapped component. | ||
| * @param {Number} yOffset - The distance between the top edge of the window | ||
| * and the top edge of the wrapped component. | ||
| * @returns {Boolean} | ||
| */ | ||
| function isOverlappingAtTop(xOffset, yOffset) { | ||
| if (typeof document.elementFromPoint !== 'function') { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. my bad without check this one. 99.1% supported browser is a high number. According to screenshot above, some very old browsers don't support it, but small percent. btw, do you mean from this comment is we need to check
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I actually meant this check which you already did: Not
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. btw, let's leave as it is now |
||
| return false; | ||
| } | ||
|
|
||
| const element = document.elementFromPoint(xOffset, yOffset); | ||
|
|
||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nab: uneccessary blank space |
||
| if (!element) { | ||
| return false; | ||
| } | ||
|
|
||
| const rect = element.getBoundingClientRect(); | ||
|
|
||
| // Ensure it's not itself + overlapping with another element by checking if the yOffset is greater than the top of the element | ||
| // and less than the bottom of the element | ||
| return yOffset > rect.top && yOffset < rect.bottom; | ||
| } | ||
|
|
||
| /** | ||
| * Generate styles for the tooltip component. | ||
| * | ||
|
|
@@ -86,9 +113,10 @@ export default function getTooltipStyles( | |
| manualShiftVertical = 0, | ||
| ) { | ||
| // Determine if the tooltip should display below the wrapped component. | ||
| // If a tooltip will try to render within GUTTER_WIDTH logical pixels of the top of the screen, | ||
| // If either a tooltip will try to render within GUTTER_WIDTH logical pixels of the top of the screen, | ||
| // Or the wrapped component is overlapping at top-left with another element | ||
| // we'll display it beneath its wrapped component rather than above it as usual. | ||
| const shouldShowBelow = (yOffset - tooltipHeight) < GUTTER_WIDTH; | ||
| const shouldShowBelow = (yOffset - tooltipHeight) < GUTTER_WIDTH || isOverlappingAtTop(xOffset, yOffset); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This line introduced an edge case regression in #17844 , more context here #17844 (comment) |
||
|
|
||
| // Determine if we need to shift the tooltip horizontally to prevent it | ||
| // from displaying too near to the edge of the screen. | ||
|
|
||

Uh oh!
There was an error while loading. Please reload this page.