Skip to content

Commit

Permalink
[material-ui][joy-ui][Tooltip] Rename mouse event handlers (#41202)
Browse files Browse the repository at this point in the history
  • Loading branch information
ZeeshanTamboli committed Feb 21, 2024
1 parent ba52e0d commit fac2137
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 16 deletions.
13 changes: 5 additions & 8 deletions packages/mui-joy/src/Tooltip/Tooltip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ const Tooltip = React.forwardRef(function Tooltip(inProps, ref) {
});
});

const handleEnter = (event: React.MouseEvent<HTMLElement>) => {
const handleMouseOver = (event: React.MouseEvent<HTMLElement>) => {
if (ignoreNonTouchEvents.current && event.type !== 'touchstart') {
return;
}
Expand All @@ -325,7 +325,7 @@ const Tooltip = React.forwardRef(function Tooltip(inProps, ref) {
}
};

const handleLeave = (event: React.MouseEvent<HTMLElement>) => {
const handleMouseLeave = (event: React.MouseEvent<HTMLElement>) => {
enterTimer.clear();
leaveTimer.start(leaveDelay, () => {
handleClose(event);
Expand All @@ -345,7 +345,7 @@ const Tooltip = React.forwardRef(function Tooltip(inProps, ref) {
handleBlurVisible(event as React.FocusEvent<HTMLElement>);
if (isFocusVisibleRef.current === false) {
setChildIsFocusVisible(false);
handleLeave(event as React.MouseEvent<HTMLElement>);
handleMouseLeave(event as React.MouseEvent<HTMLElement>);
}
};

Expand All @@ -360,7 +360,7 @@ const Tooltip = React.forwardRef(function Tooltip(inProps, ref) {
handleFocusVisible(event as React.FocusEvent<HTMLElement>);
if (isFocusVisibleRef.current === true) {
setChildIsFocusVisible(true);
handleEnter(event as React.MouseEvent<HTMLElement>);
handleMouseOver(event as React.MouseEvent<HTMLElement>);
}
};

Expand All @@ -373,9 +373,6 @@ const Tooltip = React.forwardRef(function Tooltip(inProps, ref) {
}
};

const handleMouseOver = handleEnter;
const handleMouseLeave = handleLeave;

const handleTouchStart = (event: React.TouchEvent<HTMLElement>) => {
detectTouchStart(event);
leaveTimer.clear();
Expand All @@ -391,7 +388,7 @@ const Tooltip = React.forwardRef(function Tooltip(inProps, ref) {
touchTimer.start(enterTouchDelay, () => {
(document.body.style as unknown as { WebkitUserSelect?: string }).WebkitUserSelect =
prevUserSelect.current;
handleEnter(event as unknown as React.MouseEvent<HTMLElement>);
handleMouseOver(event as unknown as React.MouseEvent<HTMLElement>);
});
};

Expand Down
13 changes: 5 additions & 8 deletions packages/mui-material/src/Tooltip/Tooltip.js
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ const Tooltip = React.forwardRef(function Tooltip(inProps, ref) {
},
);

const handleEnter = (event) => {
const handleMouseOver = (event) => {
if (ignoreNonTouchEvents.current && event.type !== 'touchstart') {
return;
}
Expand All @@ -388,7 +388,7 @@ const Tooltip = React.forwardRef(function Tooltip(inProps, ref) {
}
};

const handleLeave = (event) => {
const handleMouseLeave = (event) => {
enterTimer.clear();
leaveTimer.start(leaveDelay, () => {
handleClose(event);
Expand All @@ -408,7 +408,7 @@ const Tooltip = React.forwardRef(function Tooltip(inProps, ref) {
handleBlurVisible(event);
if (isFocusVisibleRef.current === false) {
setChildIsFocusVisible(false);
handleLeave(event);
handleMouseLeave(event);
}
};

Expand All @@ -423,7 +423,7 @@ const Tooltip = React.forwardRef(function Tooltip(inProps, ref) {
handleFocusVisible(event);
if (isFocusVisibleRef.current === true) {
setChildIsFocusVisible(true);
handleEnter(event);
handleMouseOver(event);
}
};

Expand All @@ -436,9 +436,6 @@ const Tooltip = React.forwardRef(function Tooltip(inProps, ref) {
}
};

const handleMouseOver = handleEnter;
const handleMouseLeave = handleLeave;

const handleTouchStart = (event) => {
detectTouchStart(event);
leaveTimer.clear();
Expand All @@ -451,7 +448,7 @@ const Tooltip = React.forwardRef(function Tooltip(inProps, ref) {

touchTimer.start(enterTouchDelay, () => {
document.body.style.WebkitUserSelect = prevUserSelect.current;
handleEnter(event);
handleMouseOver(event);
});
};

Expand Down

0 comments on commit fac2137

Please sign in to comment.