Skip to content

fix: lazy motion forward ref issue#2611

Merged
jrgarciadev merged 3 commits into
heroui-inc:mainfrom
wingkwong:fix/lazy-motion-forwardRef
Mar 30, 2024
Merged

fix: lazy motion forward ref issue#2611
jrgarciadev merged 3 commits into
heroui-inc:mainfrom
wingkwong:fix/lazy-motion-forwardRef

Conversation

@wingkwong
Copy link
Copy Markdown
Member

@wingkwong wingkwong commented Mar 30, 2024

Closes #

📝 Description

⛳️ Current behavior (updates)

if you run pnpm test popover or pnpm test modal, you can see the following error

  console.error
    Warning: Function components cannot be given refs. Attempts to access this ref will fail. Did you mean to use React.forwardRef()?

    Check the render method of `ForwardRef`.
        at LazyMotion (/Users/wingkwong/Documents/GitHub/nextui/node_modules/.pnpm/framer-motion@10.16.4_react-dom@18.2.0_react@18.2.0/node_modules/framer-motion/dist/cjs/index.js:4977:23)
        at /Users/wingkwong/Documents/GitHub/nextui/node_modules/.pnpm/react-remove-scroll@2.5.7_@types+react@18.2.8_react@18.2.0/node_modules/react-remove-scroll/dist/es5/UI.js:16:21
        at div
        at as (/Users/wingkwong/Documents/GitHub/nextui/packages/components/modal/src/modal-content.tsx:25:10)
        at $a7a032acae3ddda9$export$20e40289641fbbb6 (/Users/wingkwong/Documents/GitHub/nextui/node_modules/.pnpm/@react-aria+focus@3.14.3_react@18.2.0/node_modules/@react-aria/focus/dist/packages/@react-aria/focus/src/FocusScope.tsx:83:8)
        at $3596bae48579386f$export$cf75428e0b9ed1ea (/Users/wingkwong/Documents/GitHub/nextui/node_modules/.pnpm/@react-aria+interactions@3.19.1_react@18.2.0/node_modules/@react-aria/interactions/dist/packages/@react-aria/interactions/src/PressResponder.tsx:56:38)
        at $745edbb83ab4296f$export$c6fdb837b070b4ff (/Users/wingkwong/Documents/GitHub/nextui/node_modules/.pnpm/@react-aria+overlays@3.18.1_react-dom@18.2.0_react@18.2.0/node_modules/@react-aria/overlays/dist/packages/@react-aria/overlays/src/Overlay.tsx:48:22)
        at PresenceChild (/Users/wingkwong/Documents/GitHub/nextui/node_modules/.pnpm/framer-motion@10.16.4_react-dom@18.2.0_react@18.2.0/node_modules/framer-motion/dist/cjs/index.js:4706:26)
        at AnimatePresence (/Users/wingkwong/Documents/GitHub/nextui/node_modules/.pnpm/framer-motion@10.16.4_react-dom@18.2.0_react@18.2.0/node_modules/framer-motion/dist/cjs/index.js:4808:28)
        at children (/Users/wingkwong/Documents/GitHub/nextui/packages/components/modal/src/modal.tsx:17:10)

🚀 New behavior

the error is gone

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

No

📝 Additional Information

Summary by CodeRabbit

  • New Features
    • Enhanced modal and popover components with improved animation and scroll behavior control.
  • Bug Fixes
    • Fixed an issue related to lazy motion with forward references.
  • Refactor
    • Updated versions of modal and popover dependencies for better performance and stability.

@wingkwong wingkwong requested a review from jrgarciadev as a code owner March 30, 2024 15:40
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Mar 30, 2024

🦋 Changeset detected

Latest commit: c3aaec4

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

This PR includes changesets to release 6 packages
Name Type
@nextui-org/modal Patch
@nextui-org/popover Patch
@nextui-org/react Patch
@nextui-org/autocomplete Patch
@nextui-org/dropdown Patch
@nextui-org/select 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

@vercel
Copy link
Copy Markdown

vercel Bot commented Mar 30, 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 Mar 30, 2024 3:43pm

@vercel
Copy link
Copy Markdown

vercel Bot commented Mar 30, 2024

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

A member of the Team first needs to authorize it.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Mar 30, 2024

Walkthrough

The updates introduce enhancements to modal and popover components, focusing on improving the handling of animations and scroll behaviors. By integrating a RemoveScrollWrapper function, both components now offer a more refined control over content rendering, especially when animations are disabled. This approach not only streamlines the user experience but also optimizes performance by conditionally applying changes based on the disableAnimation flag.

Changes

Files Change Summary
.changeset/spicy-coats-exist.md Updated @nextui-org/modal and @nextui-org/popover versions; fixed a lazy motion forwardRef issue.
.../modal/src/modal-content.tsx Introduced RemoveScrollWrapper in ModalContent for better scroll and animation control.
.../popover/src/popover-content.tsx Added RemoveScrollWrapper in PopoverContent using useCallback for optimized rendering.

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.

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 a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @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.
  • The JSON schema for the configuration file is available here.
  • 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/coderabbit-overrides.v2.json

CodeRabbit Discord Community

Join our Discord Community to get help, request features, and share feedback.

Copy link
Copy Markdown
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: 1

Review Status

Configuration used: .coderabbit.yaml

Commits Files that changed from the base of the PR and between cf0d4e4 and c3aaec4.
Files selected for processing (3)
  • .changeset/spicy-coats-exist.md (1 hunks)
  • packages/components/modal/src/modal-content.tsx (2 hunks)
  • packages/components/popover/src/popover-content.tsx (2 hunks)
Additional Context Used
Additional comments not posted (2)
packages/components/popover/src/popover-content.tsx (1)

84-93: The RemoveScrollWrapper component is defined using useCallback for optimization. Consider adding a comment explaining its purpose and usage for future maintainability.

packages/components/modal/src/modal-content.tsx (1)

93-102: The RemoveScrollWrapper component is defined using useCallback for optimization. Consider adding a comment explaining its purpose and usage for future maintainability.

Comment thread .changeset/spicy-coats-exist.md
@jrgarciadev jrgarciadev added this to the v2.3.0 milestone Mar 30, 2024
@jrgarciadev jrgarciadev merged commit 8761168 into heroui-inc:main Mar 30, 2024
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.

2 participants