-
Notifications
You must be signed in to change notification settings - Fork 99
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
feat(ClipboardButton): delay tooltip's closing animation after copying #1735
Conversation
Preview is ready. |
Visual Tests Report is ready. |
fbebcea
to
1f74089
Compare
Passed design review. |
@lxndr Hi! Let's try not to add new props and make the case with those that are already defined in the component's api? |
@lxndr as for me, thats much better! Lets stick to this implementation and bring it to the final? |
|
||
const timerIdRef = React.useRef<number>(); | ||
const [tooltipCloseDelay, setTooltipCloseDelay] = React.useState<number | undefined>(undefined); | ||
const [tooltipDisabled, setTooltipDisabled] = React.useState<boolean>(false); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no need in generic here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
React.useEffect(() => window.clearTimeout(timerIdRef.current), []); | ||
|
||
const handleCopy: OnCopyHandler = React.useCallback( | ||
(...args) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no need in destructuring here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
if (tooltipDisabled) { | ||
setTooltipDisabled(false); | ||
setTooltipCloseDelay(undefined); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (tooltipDisabled) { | |
setTooltipDisabled(false); | |
setTooltipCloseDelay(undefined); | |
} | |
if (tooltipDisabled) { | |
setTooltipDisabled(false); | |
} | |
if (tooltipCloseDelay) { | |
setTooltipCloseDelay(undefined); | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why?
generally tooltipCloseDelay doesn't depends on tooltipDisabled? Why should we reset it if it's already undefined?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it said if (!showTooltip) {
before, so we only reset if tooltip is made hidden.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why? what if we decide not to hide tooltip? it seems we will still need to reset closingDelay.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you mean by deciding not to hide the tooltip? It has to be hidden even if the user quickly leaves and hovers the button again. We only show the tooltip if it's gone and user hovers the button afterwards.
7631ca0
to
80651db
Compare
Closes #1739