Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3370975
D8860.id30057.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Referenced Files
None
Subscribers
None
D8860.id30057.diff
View Options
diff --git a/web/utils/tooltip-utils.js b/web/utils/tooltip-utils.js
--- a/web/utils/tooltip-utils.js
+++ b/web/utils/tooltip-utils.js
@@ -48,6 +48,25 @@
+actionButtonContent: React.Node,
};
+function getTooltipScreenOverflowXCorrection(
+ xAnchor: number,
+ tooltipWidth: number,
+): number {
+ const appContainerPositionInfo = getAppContainerPositionInfo();
+ if (!appContainerPositionInfo) {
+ return 0;
+ }
+
+ const { right: containerRight } = appContainerPositionInfo;
+ const padding = 8;
+
+ const tooltipScreenOverflowX = xAnchor + tooltipWidth - containerRight;
+ const correction =
+ tooltipScreenOverflowX > 0 ? -tooltipScreenOverflowX - padding : 0;
+
+ return correction;
+}
+
type FindTooltipPositionArgs = {
+sourcePositionInfo: PositionInfo,
+tooltipSize: TooltipSize,
@@ -252,12 +271,19 @@
alignment: 'left',
};
} else if (tooltipPosition === tooltipPositions.TOP) {
+ const xAnchor =
+ sourcePositionInfo.left +
+ sourcePositionInfo.width / 2 -
+ tooltipSize.width / 2;
+
+ const tooltipOverflowXCorrection = getTooltipScreenOverflowXCorrection(
+ xAnchor,
+ tooltipSize.width,
+ );
+
return {
anchorPoint: {
- x:
- sourcePositionInfo.left +
- sourcePositionInfo.width / 2 -
- tooltipSize.width / 2,
+ x: xAnchor + tooltipOverflowXCorrection,
y: sourcePositionInfo.top,
},
horizontalPosition: 'right',
@@ -265,12 +291,19 @@
alignment: 'center',
};
} else if (tooltipPosition === tooltipPositions.BOTTOM) {
+ const xAnchor =
+ sourcePositionInfo.left +
+ sourcePositionInfo.width / 2 -
+ tooltipSize.width / 2;
+
+ const tooltipOverflowXCorrection = getTooltipScreenOverflowXCorrection(
+ xAnchor,
+ tooltipSize.width,
+ );
+
return {
anchorPoint: {
- x:
- sourcePositionInfo.left +
- sourcePositionInfo.width / 2 -
- tooltipSize.width / 2,
+ x: xAnchor + tooltipOverflowXCorrection,
y: sourcePositionInfo.bottom,
},
horizontalPosition: 'right',
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Nov 27, 4:17 AM (20 h, 36 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2587861
Default Alt Text
D8860.id30057.diff (2 KB)
Attached To
Mode
D8860: [web] introduce getTooltipScreenOverflowRightCorrection function
Attached
Detach File
Event Timeline
Log In to Comment