Skip to content

Update CustomContentOfTooltip example so that the tooltip does not jump around #328

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

Merged
merged 1 commit into from
Jun 23, 2025

Conversation

PavelVanecek
Copy link
Contributor

Workaround for recharts/recharts#5986

@PavelVanecek PavelVanecek requested a review from Copilot June 23, 2025 12:46
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR updates the custom tooltip example to prevent the tooltip container from jumping by always rendering the wrapper and toggling visibility via CSS, and adjusts how the tooltip component is passed to <Tooltip>.

  • Always render <div className="custom-tooltip"> and switch its visibility instead of conditionally returning null
  • Change <Tooltip content={<CustomTooltip />} /> to <Tooltip content={CustomTooltip} /> to pass the component directly
Comments suppressed due to low confidence (1)

src/docs/exampleComponents/Tooltip/CustomContentOfTooltip.js:75

  • [nitpick] The indentation around this conditional fragment is misaligned; matching its indentation level with the <div> opening tag will improve readability.
      {isVisible && (

return null;
const isVisible = active && payload && payload.length;
return (
<div className="custom-tooltip" style={{ visibility: isVisible ? 'visible' : 'hidden' }}>
Copy link
Preview

Copilot AI Jun 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Consider adding pointerEvents: isVisible ? 'auto' : 'none' to this style so the hidden tooltip container doesn't intercept mouse events and block interactions with underlying elements.

Suggested change
<div className="custom-tooltip" style={{ visibility: isVisible ? 'visible' : 'hidden' }}>
<div className="custom-tooltip" style={{ visibility: isVisible ? 'visible' : 'hidden', pointerEvents: isVisible ? 'auto' : 'none' }}>

Copilot uses AI. Check for mistakes.

@ckifer ckifer merged commit 1f7ba2c into master Jun 23, 2025
1 check passed
@ckifer ckifer deleted the tooltip-animation-example branch June 23, 2025 14:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants