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

Refactor Tooltip Component to Dynamically Calculate Position #1306

Closed
6 of 10 tasks
VinuB-Dev opened this issue Dec 28, 2024 · 0 comments · Fixed by #1309
Closed
6 of 10 tasks

Refactor Tooltip Component to Dynamically Calculate Position #1306

VinuB-Dev opened this issue Dec 28, 2024 · 0 comments · Fixed by #1309

Comments

@VinuB-Dev
Copy link
Contributor

VinuB-Dev commented Dec 28, 2024

Issue Description

The current tooltip implementation requires the position to be passed manually as a prop. This approach is error-prone and inconsistent, making it difficult to maintain and scale.
For example:

<Tooltip
    content={content}
    tooltipPosition={{
        top: '-3.6rem',
        right: '-4.5rem',
    }}
>

This reliance on manually calculated positions leads to inconsistent placement and potential issues like viewport overflow.

Expected Behavior

  • The tooltip component should dynamically calculate its position relative to the triggering element.
  • Tooltip placement should adjust automatically to remain within the viewport or container boundaries.
  • Developers should not need to pass position props explicitly. The component should remain simple:
<Tooltip content={content}>
    Hover me
</Tooltip>

Current Behavior

  • Tooltip position must be explicitly passed via the tooltipPosition prop.
  • Manual calculations are required by the developer for positioning, leading to inconsistency and maintenance challenges.
  • Tooltips can overflow the viewport or container, negatively impacting user experience.

Screenshots

Code example:

Screenshot 2024-12-28 at 9 53 32 AM

View:

Screenshot 2024-12-28 at 9 52 24 AM

Screenshot 2024-12-28 at 9 52 42 AM

Reproducibility

  • This issue is reproducible
  • This issue is not reproducible

Steps to Reproduce

  1. Use the Tooltip component in its current form.
  2. Pass incorrect or missing tooltipPosition props.
  3. Observe the tooltip's positioning inconsistencies or overflow behavior.

Severity/Priority

  • Critical
  • High
  • Medium
  • Low

Additional Information

  • Refactoring the tooltip to dynamically calculate its position would eliminate the recurring tooltip alignment issues.
  • This change would improve the developer experience when building components that use the tooltip, making the implementation more intuitive and reliable.

Checklist

  • I have read and followed the project's code of conduct.
  • I have searched for similar issues before creating this one.
  • I have provided all the necessary information to understand and reproduce the issue.
  • I am willing to contribute to the resolution of this issue.
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 a pull request may close this issue.

1 participant