Skip to content

Commit c94750a

Browse files
committed
Merge remote-tracking branch 'origin/fix/improveTooltipPerformanceReplacement-CMEM-6784' into fix/improveTooltipPerformanceReplacement-CMEM-6784-on-next
2 parents 6f97793 + 48bf477 commit c94750a

3 files changed

Lines changed: 18 additions & 5 deletions

File tree

src/components/Icon/IconButton.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ export const IconButton = ({
5050
const defaultIconTooltipProps = {
5151
hoverOpenDelay: 1000,
5252
openOnTargetFocus: restProps.disabled || (restProps.tabIndex ?? 0) < 0 ? false : undefined,
53+
swapPlaceholderDelay: 1,
5354
};
5455
const iconProps = {
5556
small: restProps.small,

src/components/Tooltip/Tooltip.tsx

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@ export interface TooltipProps extends Omit<BlueprintTooltipProps, "position"> {
4242
* You can prevent it in any case by setting it to `false`.
4343
*/
4444
usePlaceholder?: boolean;
45+
/**
46+
* Time after the placeholder element is replaced by the actual tooltip component. Must be greater than 0.
47+
*/
48+
swapPlaceholderDelay?: number;
4549
}
4650

4751
export const Tooltip = ({
@@ -53,18 +57,21 @@ export const Tooltip = ({
5357
markdownEnabler = "\n\n",
5458
markdownProps,
5559
usePlaceholder,
60+
swapPlaceholderDelay = 100,
5661
hoverOpenDelay = 500,
5762
...otherTooltipProps
5863
}: TooltipProps) => {
5964
const placeholderRef = React.useRef(null);
6065
const eventMemory = React.useRef<null | "afterhover" | "afterfocus">(null);
6166
const searchId = React.useRef<null | string>(null);
62-
const swapDelayTime = 100;
67+
const swapDelay = React.useRef<null | NodeJS.Timeout>(null);
68+
const swapDelayTime = swapPlaceholderDelay;
6369
const [placeholder, setPlaceholder] = React.useState<boolean>(
6470
!otherTooltipProps.disabled &&
6571
!otherTooltipProps.defaultIsOpen &&
6672
!otherTooltipProps.isOpen &&
6773
otherTooltipProps.renderTarget === undefined &&
74+
swapDelayTime > 0 &&
6875
hoverOpenDelay > swapDelayTime &&
6976
(usePlaceholder === true || (typeof content === "string" && usePlaceholder !== false))
7077
);
@@ -77,7 +84,10 @@ export const Tooltip = ({
7784
React.useEffect(() => {
7885
if (placeholderRef.current !== null) {
7986
const swap = (ev: MouseEvent | globalThis.FocusEvent) => {
80-
const swapDelay = setTimeout(() => {
87+
if (swapDelay.current) {
88+
clearTimeout(swapDelay.current);
89+
}
90+
swapDelay.current = setTimeout(() => {
8191
// we delay the swap to prevent unwanted effects
8292
// (e.g. forced mouseover after the swap but the cursor is already somewhere else)
8393
eventMemory.current = ev.type === "focusin" ? "afterfocus" : "afterhover";
@@ -93,7 +103,7 @@ export const Tooltip = ({
93103
) {
94104
eventMemory.current = null;
95105
}
96-
clearTimeout(swapDelay);
106+
clearTimeout(swapDelay.current as NodeJS.Timeout);
97107
});
98108
}
99109
};
@@ -166,7 +176,9 @@ export const Tooltip = ({
166176
) : (
167177
<BlueprintTooltip
168178
lazy={true}
169-
hoverOpenDelay={hoverOpenDelay - swapDelayTime}
179+
hoverOpenDelay={
180+
swapDelayTime > 0 && hoverOpenDelay > swapDelayTime ? hoverOpenDelay - swapDelayTime : hoverOpenDelay
181+
}
170182
{...otherTooltipProps}
171183
content={tooltipContent}
172184
className={targetClassName}

src/extensions/react-flow/nodes/NodeContent.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -661,7 +661,7 @@ export function NodeContent<CONTENT_PROPS = React.HTMLAttributes<HTMLElement>>({
661661
)}
662662
</div>
663663
{(menuButtons || (showExecutionButtons && executionButtons)) && (
664-
<div className={`${eccgui}-graphviz__node__header-menu`}>
664+
<div className={`${eccgui}-graphviz__node__header-menu nodrag`}>
665665
{showExecutionButtons && typeof executionButtons === "function"
666666
? executionButtons(adjustedContentProps, setAdjustedContentProps)
667667
: null}

0 commit comments

Comments
 (0)