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: correctly dismissable default value #4524

Open
wants to merge 2 commits into
base: canary
Choose a base branch
from

Conversation

winchesHe
Copy link
Member

@winchesHe winchesHe commented Jan 9, 2025

Closes #

📝 Description

⛳️ Current behavior (updates)

Comment default value is false

🚀 New behavior

Change to true same with the docs

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

📝 Additional Information

Summary by CodeRabbit

Release Notes

  • New Features

    • Added isDismissable option for modal and popover components
    • Default dismissability set to true for both components
  • Bug Fixes

    • Corrected default behavior for dismissing modal and popover overlays
  • Improvements

    • Enhanced component configuration with new dismissal control property

@winchesHe winchesHe requested a review from jrgarciadev as a code owner January 9, 2025 14:12
Copy link

vercel bot commented Jan 9, 2025

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 Jan 9, 2025 2:17pm
nextui-storybook-v2 ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 9, 2025 2:17pm

Copy link

changeset-bot bot commented Jan 9, 2025

🦋 Changeset detected

Latest commit: eea1e03

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

This PR includes changesets to release 8 packages
Name Type
@nextui-org/popover Patch
@nextui-org/modal Patch
@nextui-org/autocomplete Patch
@nextui-org/date-picker Patch
@nextui-org/dropdown Patch
@nextui-org/select Patch
@nextui-org/react Patch
@nextui-org/drawer 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 Jan 9, 2025

Walkthrough

The pull request introduces a new optional isDismissable property for both the modal and popover components. This property controls whether the overlay can be dismissed by user interactions outside the component. By default, the property is set to true, allowing users to close the modal or popover by clicking outside. The changes involve updating type definitions and hook implementations in the @nextui-org/modal and @nextui-org/popover packages to support this new dismissability configuration.

Changes

File Change Summary
packages/components/modal/src/use-modal.ts - Added isDismissable?: boolean property to Props interface
- Updated UseModalProps type to omit isDismissable from AriaModalOverlayProps
packages/components/popover/src/use-aria-popover.ts - Added isDismissable?: boolean property to Props interface
- Updated ReactAriaPopoverProps type to omit isDismissable from AriaOverlayProps

Possibly related PRs

Suggested reviewers

  • jrgarciadev
  • wingkwong

Finishing Touches

  • 📝 Generate Docstrings

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 generate docstrings to generate docstrings for this PR. (Beta)
  • @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.

@winchesHe winchesHe changed the title Fix/popover-dismissable-value fix: correctly dismissable default value Jan 9, 2025
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

🧹 Nitpick comments (2)
packages/components/modal/src/use-modal.ts (2)

84-87: Consider extracting shared types

Since both modal and popover components now share the isDismissable property with identical behavior, consider extracting it to a shared interface.

Example implementation:

// @nextui-org/shared-utils
interface DismissableProps {
  /**
   * Whether to close the overlay when the user interacts outside it.
   * @default true
   */
  isDismissable?: boolean;
}

// In modal and popover
interface Props extends DismissableProps {
  // ... other props
}

Line range hint 45-49: Architectural consistency achieved

The implementation of isDismissable across both modal and popover components demonstrates good architectural decisions:

  1. Consistent behavior for overlay dismissal
  2. Proper type safety with React Aria integration
  3. Backward compatibility maintained with default value
  4. Uniform documentation across components

This change improves the component library's API consistency.

Also applies to: 77-81

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between eada8cb and eea1e03.

📒 Files selected for processing (3)
  • .changeset/lucky-parrots-compete.md (1 hunks)
  • packages/components/modal/src/use-modal.ts (1 hunks)
  • packages/components/popover/src/use-aria-popover.ts (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • .changeset/lucky-parrots-compete.md
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: TypeScript
  • GitHub Check: Build
🔇 Additional comments (3)
packages/components/popover/src/use-aria-popover.ts (2)

45-49: Well-documented property addition

The JSDoc for the new isDismissable property is clear and includes the default value.


52-54: Verify type compatibility with React Aria

The type modification correctly prevents property collision by omitting isDismissable from AriaOverlayProps. However, we should ensure this aligns with the latest React Aria types.

✅ Verification successful

Type compatibility with React Aria is correct

The omission of isDismissable from AriaOverlayProps is intentional and properly implemented. The type modification follows React Aria's patterns for overlay components customization.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check React Aria version and type definitions
grep "@react-aria/overlays" package.json
cat node_modules/@react-aria/overlays/dist/types.d.ts | grep -A 5 "interface AriaOverlayProps"

Length of output: 219


Script:

#!/bin/bash
# Find all package.json files and search for react-aria dependencies
fd package.json --exec grep -l "@react-aria"

# Search for imports from @react-aria/overlays
rg "from ['\"]\@react-aria\/overlays['\"]" -A 2

# Search for AriaOverlayProps usage
rg "AriaOverlayProps"

Length of output: 2720


Script:

#!/bin/bash
# Check tooltip implementation
ast-grep --pattern 'import { $$ } from "@react-aria/overlays"' packages/components/tooltip/src/use-tooltip.ts
rg -A 10 "AriaOverlayProps" packages/components/tooltip/src/use-tooltip.ts

# Check popover implementation
ast-grep --pattern 'import { $$ } from "@react-aria/overlays"' packages/components/popover/src/use-aria-popover.ts
rg -A 10 "AriaOverlayProps" packages/components/popover/src/use-aria-popover.ts

Length of output: 1820

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

77-81: Consistent property documentation

The JSDoc for isDismissable matches the popover implementation, maintaining consistency across components.

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