Skip to content

Commit 9f106d9

Browse files
authored
Merge pull request #323 from eccenca/fix/preventWronglyDisplayedTooltips-CMEM-6858
Prevent wrongly displayed tooltips (CMEM-6858)
2 parents 26cb90f + 44aa3c1 commit 9f106d9

3 files changed

Lines changed: 17 additions & 2 deletions

File tree

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,13 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
1010

1111
- React flow v12:
1212
- add missing styles from react flow library to ensure proper functionality of new connection lines
13+
- `<Tooltip />`
14+
- re-check hover state after swapping the placeholder before triggering the event bubbling
15+
16+
## Changed
17+
18+
- `<IconButton/>`
19+
- increase the default delay before swapping the tooltip placeholder of the icon, reducing unwanted swaps because of mouseovers that were not intended
1320

1421
## [24.3.1] - 2025-08-21
1522

src/components/Icon/IconButton.tsx

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

src/components/Tooltip/Tooltip.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,15 @@ export const Tooltip = ({
134134
(target as HTMLElement).focus();
135135
break;
136136
case "afterhover":
137-
(target as HTMLElement).dispatchEvent(new MouseEvent("mouseover", { bubbles: true }));
137+
// re-check if the cursor is still over the element after swapping the placeholder before triggering the event to bubble up
138+
(target as HTMLElement).addEventListener(
139+
"mouseover",
140+
() => (target as HTMLElement).dispatchEvent(new MouseEvent("mouseover", { bubbles: true })),
141+
{
142+
capture: true,
143+
once: true,
144+
}
145+
);
138146
break;
139147
}
140148
}

0 commit comments

Comments
 (0)