Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added 500ms delay before tooltip is closed #7007

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 12 additions & 3 deletions src/js/components/Tip/Tip.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ const Tip = forwardRef(({ children, content, dropProps, plain }, tipRef) => {

const componentRef = useForwardedRef(tipRef);

const delay = () =>
new Promise((resolve) => {
setTimeout(() => resolve(), 500);
});

// Three use case for children
// 1. Tip has a single child + it is a React Element => Great!
// 2. Tip has a single child + not React Element =>
Expand All @@ -36,16 +41,20 @@ const Tip = forwardRef(({ children, content, dropProps, plain }, tipRef) => {
setOver(true);
if (child.props?.onMouseEnter) child.props.onMouseEnter(event);
},
onMouseLeave: (event) => {
onMouseLeave: async (event) => {
await delay();
setOver(false);
if (child.props?.onMouseLeave) child.props.onMouseLeave(event);
},
onFocus: (event) => {
if (usingKeyboard) setOver(true);
if (child.props?.onFocus) child.props.onFocus(event);
},
onBlur: (event) => {
if (usingKeyboard) setOver(false);
onBlur: async (event) => {
if (usingKeyboard) {
await delay();
setOver(false);
}
if (child.props?.onBlur) child.props.onBlur(event);
},
key: 'tip-child',
Expand Down