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 enforceDelayShow prop. (Fixes #1235) #1236

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Ville-Wennerlund
Copy link

@Ville-Wennerlund Ville-Wennerlund commented Nov 27, 2024

This will make the delayShow prop to always be enforced even if the tooltip instance is rendered.

This can be used for when you only have one tooltip instance, but multiple tooltip anchors, and want it to always take the delayShow amount of time before it is shown.

Summary by CodeRabbit

  • New Features
    • Introduced a new prop enforceDelayShow for the Tooltip component, allowing users to control the display timing of tooltips with more precision.
  • Improvements
    • Enhanced tooltip behavior to respect display delays even when previously rendered, providing a more consistent user experience.

This will make the delayShow prop to always be enforced even if the tooltip instance is rendered.

This can be used for when you only have one tooltip instance, but multiple tooltip anchors, and want it to always take the delayShow amount of time before it is shown.
Copy link

coderabbitai bot commented Nov 27, 2024

Walkthrough

The changes introduce a new optional prop enforceDelayShow to the Tooltip component, allowing for enhanced control over the tooltip's display timing. This prop modifies the behavior of the handleShowTooltipDelayed function, ensuring that the tooltip respects the delay even if it has been rendered previously when set to true. The overall structure and logic of the component remain unchanged, and the existing functionality continues to operate as before.

Changes

File Change Summary
src/components/Tooltip/Tooltip.tsx Added new prop enforceDelayShow to control tooltip display timing.
src/components/Tooltip/TooltipTypes.d.ts Introduced optional property enforceDelayShow?: boolean in ITooltip interface.

Possibly related PRs

  • feat: support for disabled tooltip callback #1211: The main PR introduces a new prop enforceDelayShow to the Tooltip component, while this retrieved PR adds a different prop disableTooltip. Both changes modify the behavior of the Tooltip component, indicating they are related in terms of enhancing tooltip functionality.

Suggested labels

Feature, Awaiting merge

Suggested reviewers

  • gabrieljablonski

Poem

In the garden where tooltips play,
A new prop joins the fray today.
With enforceDelayShow in sight,
Timing’s perfect, oh what a delight!
Hopping through code, we cheer and sway,
For smoother tooltips, hip-hip-hooray! 🐇✨


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>, please review it.
    • 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 gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @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 using 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.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration 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

@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

🧹 Outside diff range and nitpick comments (2)
src/components/Tooltip/TooltipTypes.d.ts (1)

161-161: Add JSDoc documentation for the new prop

The type definition is correct and well-placed near other delay-related props. However, consider adding JSDoc documentation to explain its purpose and relationship with delayShow.

+  /**
+   * @description When true, ensures delayShow is always respected, even if the tooltip was previously rendered
+   */
   enforceDelayShow?: boolean
src/components/Tooltip/Tooltip.tsx (1)

Line range hint 263-267: Add a comment explaining the enforceDelayShow behavior.

While the logic is correct, adding a comment would help future maintainers understand the purpose of enforceDelayShow and its impact on delay behavior.

+    // When enforceDelayShow is true, always apply the delay
+    // even if the tooltip was previously rendered
     if (rendered && !enforceDelayShow) {
       // if the tooltip is already rendered, ignore delay
       handleShow(true)
       return
     }
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 08bfc6f and adf51a5.

📒 Files selected for processing (2)
  • src/components/Tooltip/Tooltip.tsx (2 hunks)
  • src/components/Tooltip/TooltipTypes.d.ts (1 hunks)
🔇 Additional comments (2)
src/components/Tooltip/Tooltip.tsx (2)

71-71: LGTM! Well-defined prop with clear naming.

The new prop enforceDelayShow is properly declared with a sensible default value that maintains backward compatibility.


71-71: Implementation successfully addresses the PR objectives.

The changes effectively solve issue #1235 by:

  1. Adding a new opt-in prop enforceDelayShow
  2. Maintaining backward compatibility with default false value
  3. Implementing the delay enforcement logic correctly

Also applies to: 263-267

@Ville-Wennerlund
Copy link
Author

I went back to version 5.24.0.
Essentially before the skip if rendered was added. Tooltip.jsx row 260ish.

And I assume I would get the same issues with my changes that I am proposing. That the tooltip blinks between the old anchor value and the new anchor value.

@Ville-Wennerlund Ville-Wennerlund marked this pull request as draft November 27, 2024 14:01
@gabrieljablonski
Copy link
Member

I went back to version 5.24.0.

Tried approving the beta release so you could use it in your package until we have time to review this, but it didn't work. But since 5.24.0 apparently solved it for you, it's fine for now then.

Thanks for the contribution, will go over it when I have the time.

@Ville-Wennerlund
Copy link
Author

Ville-Wennerlund commented Nov 27, 2024

I think you misunderstood me.

What I'm trying to say is that 5.24.0 and my proposed changes will probably behave the same.

5.24.0 has the issue that if you hover between anchors that have the same tooltip instance, the tooltip will first disappear and reappear on the new anchor.

I will see if I can find a related issue to link to you, since I hope that someone else can explain it better than me : )

Edit:
this issue:
#1162
and your changes that fixed that issue:
https://github.com/ReactTooltip/react-tooltip/pull/1168/files

@Ville-Wennerlund
Copy link
Author

Hi!
Have you had a chance to look at my latest comment?

@gabrieljablonski
Copy link
Member

@Ville-Wennerlund sorry haven't had much time to go over stuff here.

Your change is simple enough, that I don't think it should break anything.

But please update the options table on the docs, and I'll do a quick test later and possibly do a release with the new option.

@Ville-Wennerlund
Copy link
Author

I think you misunderstood me.

What I'm trying to say is that 5.24.0 and my proposed changes will probably behave the same.

5.24.0 has the issue that if you hover between anchors that have the same tooltip instance, the tooltip will first disappear and reappear on the new anchor.

I will see if I can find a related issue to link to you, since I hope that someone else can explain it better than me : )

Edit: this issue: #1162 and your changes that fixed that issue: https://github.com/ReactTooltip/react-tooltip/pull/1168/files

I'm referring to this comment.
I understand that you do not have the time, we will have to do some kind of work around for the time being.

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.

[BUG] When using the same single tooltip on a page, the delayShow/data-tooltip-delay-show is not respected
2 participants