Page MenuHomePhorge

D4909.1765195928.diff
No OneTemporary

Size
2 KB
Referenced Files
None
Subscribers
None

D4909.1765195928.diff

diff --git a/web/chat/tooltip-provider.js b/web/chat/tooltip-provider.js
--- a/web/chat/tooltip-provider.js
+++ b/web/chat/tooltip-provider.js
@@ -5,6 +5,8 @@
import type { TooltipPositionStyle } from './tooltip-utils';
+const onMouseLeaveSourceDisappearTimeoutMs = 200;
+
export type RenderTooltipParams = {
+newNode: React.Node,
+tooltipPosition: TooltipPositionStyle,
@@ -46,9 +48,52 @@
setTooltipPosition,
] = React.useState<?TooltipPositionStyle>(null);
- const clearCurrentTooltip = React.useCallback(() => {}, []);
-
- const renderTooltip = React.useCallback(() => {}, []);
+ const clearTooltip = React.useCallback((tooltipToClose: symbol) => {
+ if (tooltipSymbol.current !== tooltipToClose) {
+ return;
+ }
+ tooltipCancelTimer.current = null;
+ setTooltipNode(null);
+ setTooltipPosition(null);
+ tooltipSymbol.current = null;
+ }, []);
+
+ const clearCurrentTooltip = React.useCallback(() => {
+ if (tooltipSymbol.current) {
+ clearTooltip(tooltipSymbol.current);
+ }
+ }, [clearTooltip]);
+
+ const renderTooltip = React.useCallback(
+ ({
+ newNode,
+ tooltipPosition: newTooltipPosition,
+ }: RenderTooltipParams): RenderTooltipResult => {
+ if (!newNode || !newTooltipPosition) {
+ return { onMouseLeaveCallback: () => {}, clearTooltip: () => {} };
+ }
+ setTooltipNode(newNode);
+ setTooltipPosition(newTooltipPosition);
+ const newNodeSymbol = Symbol();
+ tooltipSymbol.current = newNodeSymbol;
+
+ if (tooltipCancelTimer.current) {
+ clearTimeout(tooltipCancelTimer.current);
+ }
+
+ return {
+ onMouseLeaveCallback: () => {
+ const newTimer = setTimeout(
+ () => clearTooltip(newNodeSymbol),
+ onMouseLeaveSourceDisappearTimeoutMs,
+ );
+ tooltipCancelTimer.current = newTimer;
+ },
+ clearTooltip: () => clearTooltip(newNodeSymbol),
+ };
+ },
+ [clearTooltip],
+ );
// eslint-disable-next-line no-unused-vars
const onMouseEnterTooltip = React.useCallback(() => {}, []);

File Metadata

Mime Type
text/plain
Expires
Mon, Dec 8, 12:12 PM (5 h, 21 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5848174
Default Alt Text
D4909.1765195928.diff (2 KB)

Event Timeline