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

fix(tooltip): Tooltip shouldBlockScroll doesn't work #3475

Closed
wants to merge 7 commits into from

Conversation

sayyedfaisal06
Copy link

@sayyedfaisal06 sayyedfaisal06 commented Jul 15, 2024

Closes #3474

📝 Description

This pull request addresses a bug (#3474) where scrolling was occurring when tooltip was open. The issue was causing unintended scrolling behavior that disrupted user experience.

⛳️ Current behavior (updates)

When a tooltip is open, users are able to scroll the page. This unintended scrolling can cause the tooltip to move out of view or create confusion for users.

🚀 New behavior

When a tooltip is open, the page scrolling is disabled. The tooltip remains in a fixed position relative to its target, ensuring it stays visible and does not move out of view.

💣 Is this a breaking change (Yes/No):

Yes, as the tooltip when open it will stop scrolling.

📝 Additional Information

Summary by CodeRabbit

  • New Features
    • Added a new shouldBlockScroll option to tooltips to control scrolling behavior, preventing accidental scrolling when the tooltip is open.

Copy link

vercel bot commented Jul 15, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
nextui-storybook-v2 ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 16, 2024 9:07am

Copy link

vercel bot commented Jul 15, 2024

Someone is attempting to deploy a commit to the NextUI Inc Team on Vercel.

A member of the Team first needs to authorize it.

Copy link

changeset-bot bot commented Jul 15, 2024

🦋 Changeset detected

Latest commit: 7da6c28

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 4 packages
Name Type
@nextui-org/tooltip Patch
@nextui-org/slider Patch
@nextui-org/snippet Patch
@nextui-org/react Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link
Contributor

coderabbitai bot commented Jul 15, 2024

Walkthrough

The updates implement a new shouldBlockScroll property in the @nextui-org/tooltip component to control the scrolling behavior when tooltips are open. This property, now part of the useTooltip function, ensures that the content underneath the tooltip cannot be scrolled when the tooltip is displayed. Changes were also made to the stories to demonstrate this functionality.

Changes

Files Change Summary
packages/components/tooltip/src/use-tooltip.ts Introduced shouldBlockScroll property to control scrolling behavior, updated imports to include useMemo, useRef, and useCallback for enhanced functionality.
packages/components/tooltip/stories/tooltip.stories.tsx Added new exports DisableScrollbar and OpenChange, incorporating the shouldBlockScroll property to demonstrate its usage.

Assessment against linked issues

Objective Addressed Explanation
Tooltip shouldBlockScroll doesn't work (#3474)

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 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
Contributor

@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.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between b762141 and 63b50a9.

Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
Files selected for processing (6)
  • .changeset/modern-pianos-destroy.md (1 hunks)
  • packages/components/popover/src/popover-content.tsx (1 hunks)
  • packages/components/tooltip/package.json (1 hunks)
  • packages/components/tooltip/src/tooltip.tsx (4 hunks)
  • packages/components/tooltip/src/use-tooltip.ts (6 hunks)
  • packages/components/tooltip/stories/tooltip.stories.tsx (3 hunks)
Files skipped from review due to trivial changes (1)
  • packages/components/popover/src/popover-content.tsx
Additional comments not posted (7)
.changeset/modern-pianos-destroy.md (1)

1-5: Changeset file is accurate and complete.

The changeset correctly reflects the major version update and the bug fix for issue #3474.

packages/components/tooltip/package.json (1)

37-41: Dependency addition is correct.

The react-remove-scroll dependency is correctly added, and other configurations remain intact.

Also applies to: 46-47, 55-56

packages/components/tooltip/src/tooltip.tsx (1)

9-9: Integration of RemoveScroll and handling of shouldBlockScroll are correct.

The RemoveScroll component is correctly integrated, and the shouldBlockScroll property is properly handled to manage scrolling behavior.

Also applies to: 57-57, 79-94

packages/components/tooltip/src/use-tooltip.ts (1)

7-7: Handling of shouldBlockScroll in useTooltip is correct.

The shouldBlockScroll property is correctly integrated and handled within the useTooltip hook to manage scrolling behavior.

Also applies to: 20-20, 83-86, 128-128, 253-253, 268-268

packages/components/tooltip/stories/tooltip.stories.tsx (3)

41-45: LGTM! Adding shouldBlockScroll to argTypes is appropriate.

This change allows users to control the shouldBlockScroll property through the Storybook UI.


291-296: LGTM! The DisbaleScrollbar export is well-defined.

This export demonstrates the usage of the shouldBlockScroll property by disabling scroll blocking.


395-395: LGTM! The AlwaysOpen export is well-defined.

This export demonstrates the usage of the shouldBlockScroll property by enabling scroll blocking.

@sayyedfaisal06 sayyedfaisal06 changed the title fix #3474: Tooltip shouldBlockScroll doesn't work fix: Tooltip shouldBlockScroll doesn't work #3474 Jul 15, 2024
@sayyedfaisal06 sayyedfaisal06 changed the title fix: Tooltip shouldBlockScroll doesn't work #3474 fix: Tooltip shouldBlockScroll doesn't work Jul 15, 2024
@sayyedfaisal06 sayyedfaisal06 changed the title fix: Tooltip shouldBlockScroll doesn't work fix(tooltip): Tooltip shouldBlockScroll doesn't work Jul 15, 2024
Copy link
Contributor

@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.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 63b50a9 and ed502b8.

Files selected for processing (1)
  • .changeset/modern-pianos-destroy.md (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • .changeset/modern-pianos-destroy.md

.changeset/modern-pianos-destroy.md Outdated Show resolved Hide resolved
packages/components/tooltip/src/use-tooltip.ts Outdated Show resolved Hide resolved
packages/components/tooltip/src/use-tooltip.ts Outdated Show resolved Hide resolved
packages/components/tooltip/stories/tooltip.stories.tsx Outdated Show resolved Hide resolved
@@ -380,6 +392,7 @@ export const AlwaysOpen = {
...defaultProps,
isOpen: true,
showArrow: true,
shouldBlockScroll: true,
Copy link
Member

Choose a reason for hiding this comment

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

default is true already

Copy link
Author

Choose a reason for hiding this comment

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

Changes Done

Copy link
Member

Choose a reason for hiding this comment

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

remove this line

Copy link
Author

Choose a reason for hiding this comment

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

line removed

Copy link
Contributor

@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.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between ed502b8 and 6991fa0.

Files selected for processing (3)
  • .changeset/modern-pianos-destroy.md (1 hunks)
  • packages/components/tooltip/src/use-tooltip.ts (6 hunks)
  • packages/components/tooltip/stories/tooltip.stories.tsx (3 hunks)
Files skipped from review as they are similar to previous changes (3)
  • .changeset/modern-pianos-destroy.md
  • packages/components/tooltip/src/use-tooltip.ts
  • packages/components/tooltip/stories/tooltip.stories.tsx

Copy link
Member

@wingkwong wingkwong left a comment

Choose a reason for hiding this comment

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

i think there is no need to add DisableScrollbar and update AlwaysOpen in tooltip.stories.tsx. Just adding L41 - L45 is fine.

packages/components/tooltip/stories/tooltip.stories.tsx Outdated Show resolved Hide resolved
@@ -380,6 +392,7 @@ export const AlwaysOpen = {
...defaultProps,
isOpen: true,
showArrow: true,
shouldBlockScroll: true,
Copy link
Member

Choose a reason for hiding this comment

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

remove this line

Copy link
Contributor

@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.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 6991fa0 and 2c0449f.

Files selected for processing (1)
  • packages/components/tooltip/stories/tooltip.stories.tsx (2 hunks)
Files skipped from review as they are similar to previous changes (1)
  • packages/components/tooltip/stories/tooltip.stories.tsx

Copy link
Contributor

@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.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 2c0449f and 7da6c28.

Files selected for processing (1)
  • packages/components/tooltip/src/use-tooltip.ts (6 hunks)
Files skipped from review as they are similar to previous changes (1)
  • packages/components/tooltip/src/use-tooltip.ts

@wingkwong wingkwong assigned jrgarciadev and unassigned wingkwong Jul 17, 2024
@wingkwong wingkwong added this to the v2.4.3 milestone Jul 17, 2024
Comment on lines +79 to 80
<RemoveScroll enabled={shouldBlockScroll && isOpen} removeScrollBar={false}>
{trigger}
Copy link
Contributor

Choose a reason for hiding this comment

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

@wingkwong

This causes the trigger to be wrapped in a div. RemoveScroll should be wrapped in content!?

Why not use the usePreventScroll Hook?

Copy link
Member

Choose a reason for hiding this comment

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

@chirokas That's a good point. I forgot you've made that PR already. Can you also apply the changes in your PR so that I could close this one?

@jrgarciadev jrgarciadev modified the milestones: v2.4.3, v2.5.0 Jul 17, 2024
@wingkwong
Copy link
Member

Closing - will be handled in #3307 using usePreventScroll approach

@wingkwong wingkwong closed this Jul 18, 2024
@sayyedfaisal06 sayyedfaisal06 deleted the fix/tooltip branch July 18, 2024 05:11
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] - Tooltip shouldBlockScroll doesn't work
4 participants