Page MenuHomePhorge

D14106.1768822190.diff
No OneTemporary

Size
2 KB
Referenced Files
None
Subscribers
None

D14106.1768822190.diff

diff --git a/native/tooltip/tooltip.react.js b/native/tooltip/tooltip.react.js
--- a/native/tooltip/tooltip.react.js
+++ b/native/tooltip/tooltip.react.js
@@ -150,6 +150,7 @@
+closeTooltip: () => mixed,
+boundTooltipItem: React.ComponentType<TooltipItemBaseProps>,
+margin: number,
+ +tooltipHeight: number,
};
export type TooltipMenuProps<RouteName> = {
@@ -197,12 +198,12 @@
this.tooltipVerticalAbove = interpolateNode(position, {
inputRange: [0, 1],
- outputRange: [this.props.margin + this.tooltipHeight / 2, 0],
+ outputRange: [this.props.margin + this.props.tooltipHeight / 2, 0],
extrapolate: Extrapolate.CLAMP,
});
this.tooltipVerticalBelow = interpolateNode(position, {
inputRange: [0, 1],
- outputRange: [-this.props.margin - this.tooltipHeight / 2, 0],
+ outputRange: [-this.props.margin - this.props.tooltipHeight / 2, 0],
extrapolate: Extrapolate.CLAMP,
});
@@ -229,14 +230,6 @@
Haptics.impactAsync();
}
- get tooltipHeight(): number {
- if (this.props.route.params.tooltipLocation === 'fixed') {
- return fixedTooltipHeight;
- } else {
- return tooltipHeight(this.props.tooltipContext.getNumVisibleEntries());
- }
- }
-
get tooltipLocation(): 'above' | 'below' | 'fixed' {
const { params } = this.props.route;
const { tooltipLocation } = params;
@@ -251,8 +244,7 @@
const boundsTop = verticalBounds.y;
const boundsBottom = verticalBounds.y + verticalBounds.height;
- const { tooltipHeight: curTooltipHeight } = this;
- const fullHeight = curTooltipHeight + this.props.margin;
+ const fullHeight = this.props.tooltipHeight + this.props.margin;
if (
contentBottom + fullHeight > boundsBottom &&
contentTop - fullHeight > boundsTop
@@ -368,6 +360,7 @@
closeTooltip,
boundTooltipItem,
margin,
+ tooltipHeight,
...navAndRouteForFlow
} = this.props;
@@ -563,6 +556,14 @@
: 20;
}, [params.margin]);
+ const tooltipHeight = React.useMemo(() => {
+ if (tooltipLocation === 'fixed') {
+ return fixedTooltipHeight;
+ } else {
+ return getTooltipHeight(tooltipContext.getNumVisibleEntries());
+ }
+ }, [tooltipLocation, tooltipContext]);
+
return (
<Tooltip
{...rest}
@@ -574,6 +575,7 @@
closeTooltip={closeTooltip}
boundTooltipItem={boundTooltipItem}
margin={margin}
+ tooltipHeight={tooltipHeight}
/>
);
}
@@ -601,7 +603,7 @@
return React.memo<BaseTooltipPropsType>(MemoizedTooltip);
}
-function tooltipHeight(numEntries: number): number {
+function getTooltipHeight(numEntries: number): number {
// 10 (triangle) + 37 * numEntries (entries) + numEntries - 1 (padding)
return 9 + 38 * numEntries;
}

File Metadata

Mime Type
text/plain
Expires
Mon, Jan 19, 11:29 AM (18 h, 35 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5956097
Default Alt Text
D14106.1768822190.diff (2 KB)

Event Timeline