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

Clear timeout refs correctly #1205

Merged
merged 1 commit into from
Jul 3, 2024
Merged

Clear timeout refs correctly #1205

merged 1 commit into from
Jul 3, 2024

Conversation

gabrieljablonski
Copy link
Member

@gabrieljablonski gabrieljablonski commented Jul 2, 2024

Closes #1182
Closes #1204.

See comment here for demo of issue.

See same demo here, fixed with beta release.

Keep in mind this change should not revert fix from #1168 (related to issue #1119, also see sample code).

Summary by CodeRabbit

  • Bug Fixes

    • Improved tooltip reliability by using a custom timeout handler to prevent premature hiding or showing of tooltips.
  • Tests

    • Added unit tests to ensure the new timeout handler functions correctly.

Copy link

coderabbitai bot commented Jul 2, 2024

Walkthrough

The update replaces clearTimeout calls with a custom clearTimeoutRef function across the codebase. This change aims to improve how timeouts are cleared by handling them via a mutable ref object, enhancing the reliability and readability of the tooltip handling logic.

Changes

Files Change Summary
src/components/Tooltip/Tooltip.tsx Replaced clearTimeout with clearTimeoutRef to manage various timer references used in tooltip show and hide delays.
src/test/utils.spec.js Introduced clearTimeoutRef in the test suite, including a new describe block to test its behavior and verify it clears a timeout reference correctly.
src/utils/clear-timeout-ref.ts Added a new file defining the clearTimeoutRef function that clears a timeout referenced by a mutable ref object in React.
src/utils/index.ts Included clearTimeoutRef in the exports.

Assessment against linked issues

Objective Addressed Explanation
Fix regression from v5.26.0 identified in issue #1042 (#1182)

Poem

Amid the code, time well spent,
No more lost in timeout's tent,
With refs we now clear,
Bugs will disappear,
Tooltip's flow, smooth and content.

Tip

AI model upgrade

gpt-4o model for reviews and chat is now live

OpenAI claims that this model is better at understanding and generating code than the previous models. Please join our Discord Community to provide any feedback or to report any issues.


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

github-actions bot commented Jul 2, 2024

Beta version released with the last commit 🚀

yarn add react-tooltip@5.27.0-beta.1205.rc.0

or

npm install react-tooltip@5.27.0-beta.1205.rc.0

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between d23da63 and 37f0603.

Files selected for processing (4)
  • src/components/Tooltip/Tooltip.tsx (11 hunks)
  • src/test/utils.spec.js (2 hunks)
  • src/utils/clear-timeout-ref.ts (1 hunks)
  • src/utils/index.ts (2 hunks)
Additional comments not posted (15)
src/utils/clear-timeout-ref.ts (1)

1-7: LGTM!

The clearTimeoutRef function is well-implemented and follows best practices.

src/utils/index.ts (2)

9-9: LGTM!

The import statement for clearTimeoutRef is correct and follows the existing pattern.


20-20: LGTM!

The export statement for clearTimeoutRef is correct and follows the existing pattern.

src/test/utils.spec.js (1)

260-274: LGTM!

The test case for clearTimeoutRef is well-implemented and verifies the functionality correctly.

src/components/Tooltip/Tooltip.tsx (11)

11-11: LGTM!

The import statement for clearTimeoutRef is correct and follows the existing pattern.


227-227: LGTM!

The replacement of clearTimeout with clearTimeoutRef for missedTransitionTimerRef is correct and ensures the timeout reference is cleared properly.


259-259: LGTM!

The replacement of clearTimeout with clearTimeoutRef for tooltipShowDelayTimerRef is correct and ensures the timeout reference is cleared properly.


273-273: LGTM!

The replacement of clearTimeout with clearTimeoutRef for tooltipHideDelayTimerRef is correct and ensures the timeout reference is cleared properly.


305-305: LGTM!

The replacement of clearTimeout with clearTimeoutRef for tooltipHideDelayTimerRef is correct and ensures the timeout reference is cleared properly.


318-318: LGTM!

The replacement of clearTimeout with clearTimeoutRef for tooltipShowDelayTimerRef is correct and ensures the timeout reference is cleared properly.


380-380: LGTM!

The replacement of clearTimeout with clearTimeoutRef for tooltipShowDelayTimerRef is correct and ensures the timeout reference is cleared properly.


689-689: LGTM!

The replacement of clearTimeout with clearTimeoutRef for tooltipShowDelayTimerRef is correct and ensures the timeout reference is cleared properly.


690-690: LGTM!

The replacement of clearTimeout with clearTimeoutRef for tooltipHideDelayTimerRef is correct and ensures the timeout reference is cleared properly.


778-778: LGTM!

The replacement of clearTimeout with clearTimeoutRef for tooltipShowDelayTimerRef is correct and ensures the timeout reference is cleared properly.


779-779: LGTM!

The replacement of clearTimeout with clearTimeoutRef for tooltipHideDelayTimerRef is correct and ensures the timeout reference is cleared properly.

@gabrieljablonski gabrieljablonski merged commit 3e34982 into master Jul 3, 2024
7 checks passed
@gabrieljablonski gabrieljablonski deleted the fix/delay-show branch July 3, 2024 15:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
2 participants