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(dropdown): unnecessary ref in dropdown #4278

Merged
merged 1 commit into from
Dec 8, 2024
Merged

Conversation

wingkwong
Copy link
Member

@wingkwong wingkwong commented Dec 8, 2024

Closes #4245

📝 Description

In #4198, forwardRef has been removed from PopoverTrigger since the ref is not used there. The reported warning was caused by passing ref to PopoverTrigger, which no longer accepts. Since the ref will not be used, this PR is to avoid passing the unnecessary ref to PopoverTrigger.

⛳️ Current behavior (updates)

🚀 New behavior

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

📝 Additional Information

Summary by CodeRabbit

  • Bug Fixes

    • Resolved an issue with the dropdown component by removing an unnecessary reference, improving functionality and performance.
  • New Features

    • Simplified the getMenuTriggerProps method in the dropdown component for easier usage and clarity.

@wingkwong wingkwong added this to the v2.6.5 milestone Dec 8, 2024
Copy link

vercel bot commented Dec 8, 2024

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

Name Status Preview Comments Updated (UTC)
nextui-docs-v2 ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 8, 2024 10:37am
nextui-storybook-v2 ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 8, 2024 10:37am

Copy link

changeset-bot bot commented Dec 8, 2024

🦋 Changeset detected

Latest commit: 0d0b8ce

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

This PR includes changesets to release 2 packages
Name Type
@nextui-org/dropdown 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 Dec 8, 2024

Walkthrough

This pull request implements a patch for the @nextui-org/dropdown package, specifically addressing a ref warning issue in the dropdown component as reported in issue #4245. The changes include modifications to the use-dropdown.ts file, where the getMenuTriggerProps function's signature has been simplified by removing an unnecessary parameter. This update streamlines the handling of menu trigger properties and aligns the type definitions accordingly.

Changes

File Path Change Summary
.changeset/soft-pugs-travel.md Patch applied for @nextui-org/dropdown addressing a ref warning issue.
packages/components/dropdown/src/use-dropdown.ts Updated getMenuTriggerProps method signature by removing the _ref parameter; adjusted UseDropdownReturn type accordingly.

Assessment against linked issues

Objective Addressed Explanation
Resolve ref warning in DropdownTrigger (issue #4245)

Possibly related issues

Possibly related PRs

  • fix(dropdown): _a2.find is not a function #3762: This PR addresses a bug in the Dropdown component related to an error with _a2.find, which is directly connected to the changes made in the main PR that also focuses on the dropdown functionality.
  • fix: dropdown onPress issue #3211: This PR fixes an issue with keyboard interactions in the dropdown component, which relates to the overall functionality of the dropdown being improved in the main PR.
  • fix: forwardRef render functions not using ref #4198: This PR modifies the DropdownTrigger component to ensure it correctly utilizes refs, which is relevant to the changes made in the main PR regarding the dropdown component's functionality.

Suggested reviewers

  • jrgarciadev
  • winchesHe

📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between a50aa3e and 0d0b8ce.

📒 Files selected for processing (2)
  • .changeset/soft-pugs-travel.md (1 hunks)
  • packages/components/dropdown/src/use-dropdown.ts (2 hunks)
🔇 Additional comments (4)
.changeset/soft-pugs-travel.md (1)

1-5: LGTM! Appropriate version bump and clear commit message.

The patch version bump is correct for this bug fix, and the commit message properly references the issue being fixed.

packages/components/dropdown/src/use-dropdown.ts (3)

167-172: LGTM! Correctly removes unnecessary ref handling.

The simplified implementation properly removes the ref parameter while maintaining the essential functionality. This change aligns with the PR objective and resolves the console warning about function components not accepting refs.


222-222: LGTM! Type definition matches implementation.

The updated type signature correctly reflects the removal of the ref parameter from getMenuTriggerProps.


Line range hint 167-222: Verify PopoverTrigger compatibility.

Let's verify that no components rely on the removed ref functionality.

✅ Verification successful

Changes to getMenuTriggerProps are safe to proceed

Based on the codebase analysis:

  1. The only usage of getMenuTriggerProps is in dropdown-trigger.tsx where it's passed directly to PopoverTrigger without any ref handling.
  2. The PopoverTrigger component implementation shows it handles its own ref through the usePopoverContext, and doesn't expect refs from its props.
  3. The removed ref functionality from getMenuTriggerProps was unused and redundant since the trigger ref handling is managed by the Popover component.
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for any direct usage of getMenuTriggerProps that might expect a ref parameter
rg -l 'getMenuTriggerProps.*ref' --type ts

# Search for PopoverTrigger implementation to confirm it doesn't use refs
ast-grep --pattern 'export const PopoverTrigger = $$$'

Length of output: 101


Script:

#!/bin/bash
# Let's try a broader search for getMenuTriggerProps usage
rg -A 5 "getMenuTriggerProps" --type ts

# Search for PopoverTrigger in a different way
fd -e ts -e tsx -x cat {} \; | rg -A 10 "PopoverTrigger"

# Look for any files that might be using the Dropdown component
rg -l "useDropdown" --type ts

Length of output: 18745


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.

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.

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] - 2.6.2 PopoverTrigger via DropdownTrigger ref warning in console
2 participants