Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F32177174
D4909.1765069457.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
D4909.1765069457.diff
View Options
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,
+tooltipPositionStyle: TooltipPositionStyle,
@@ -49,11 +51,48 @@
setTooltipPosition,
] = React.useState<?TooltipPositionStyle>(null);
- const clearCurrentTooltip = 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(
- () => ({ onMouseLeaveCallback: () => {}, clearTooltip: () => {} }),
- [],
+ ({
+ newNode,
+ tooltipPositionStyle: newTooltipPosition,
+ }: RenderTooltipParams): RenderTooltipResult => {
+ 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
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Dec 7, 1:04 AM (2 h, 47 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5841812
Default Alt Text
D4909.1765069457.diff (1 KB)
Attached To
Mode
D4909: [web] Introduce `clearTooltip` and `renderTooltip` functions in `TooltipContext`
Attached
Detach File
Event Timeline
Log In to Comment