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

feat(components): you can now place a close button within the popover #2275

Conversation

kght6123
Copy link
Contributor

@kght6123 kght6123 commented Jan 22, 2024

スクリーンショット 2024-01-22 23 08 37

Closes #2270

📝 Description

You can now place a close button within the popover.

⛳️ Current behavior (updates)

Currently, when a function is specified in children, it only has titleProps as an argument. Therefore, I have added onClose as a second argument.

🚀 New behavior

By adding onClose to the arguments of the function that can be passed to children in popover-content.tsx, you can now add a close process to any button or similar element.

I have also corrected the onClose of the DismissButton, which is added for accessibility, since its closing process is different from that of clicking the background of the Popover. This difference might cause issues on touch devices as mentioned in the issue.
https://react-spectrum.adobe.com/react-aria/usePopover.html#example

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

No

📝 Additional Information

Nothing.

Summary by CodeRabbit

  • New Features

    • Introduced the ability to add a close button within the popover's content, enhancing user control.
    • Added a new story template featuring a popover with an onClose button for better demonstration and testing.
  • Enhancements

    • Improved interaction by enabling the closing of popovers when the backdrop is clicked, through a new dedicated callback function.
  • Refactor

    • Enhanced the PopoverContent component to support passing an onClose function, improving component flexibility and functionality.

@kght6123 kght6123 requested a review from jrgarciadev as a code owner January 22, 2024 14:24
Copy link

changeset-bot bot commented Jan 22, 2024

🦋 Changeset detected

Latest commit: 04e69be

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/popover Patch
@nextui-org/autocomplete Patch
@nextui-org/date-picker Patch
@nextui-org/dropdown Patch
@nextui-org/select 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

vercel bot commented Jan 22, 2024

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

A member of the Team first needs to authorize it.

Copy link

vercel bot commented Jan 22, 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 Apr 21, 2024 1:51pm

.changeset/quick-needles-cross.md Outdated Show resolved Hide resolved
@wingkwong
Copy link
Member

@kght6123 can you resolve the conflicts and add some tests?

Copy link
Contributor

coderabbitai bot commented Apr 21, 2024

Walkthrough

The updates primarily focus on enhancing the Popover component's functionality and usability across different devices, particularly touch devices. Changes include the introduction of an onClose function within the popover content, better state management for open/close actions, and the addition of a new story template to demonstrate the close button functionality within the popover. These modifications aim to resolve issues with popover behavior on touch devices and improve code maintainability.

Changes

File Path Change Summary
.../popover/src/popover-content.tsx Added useRef, modified import of forwardRef, updated PopoverContentProps and PopoverContent.
.../popover/src/use-popover.ts Added onClosePopover function, updated onClick handler and onClose prop usage.
.../popover/stories/popover.stories.tsx Added WithOnCloseTemplate story template.
.changeset/quick-needles-cross.md Introduced the ability to place a close button within the popover's content.

Assessment against linked issues

Objective Addressed Explanation
Resolve popover open control issue on touch devices with backdrop option (#2270)
Ensure popover can include an internal close button (#2270)
Improve code readability and maintainability (#2270)

Recent Review Details

Configuration used: .coderabbit.yaml

Commits Files that changed from the base of the PR and between 3728976 and 04e69be.
Files selected for processing (1)
  • packages/components/popover/src/popover-content.tsx (3 hunks)
Files skipped from review as they are similar to previous changes (1)
  • packages/components/popover/src/popover-content.tsx

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.
  • 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: 1

packages/components/popover/src/popover-content.tsx Outdated Show resolved Hide resolved
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
@kght6123
Copy link
Contributor Author

@wingkwong
The dispute has been resolved. Please check.

What are tests? Where and what kind of tests should I add?
Due to the current busy schedule, the fix may take until the end of May.
We apologize for the inconvenience, but please let us know.

@wingkwong
Copy link
Member

@kght6123 See packages/components/popover/__tests__/popover.test.tsx. You should add the test to cover the logic in introduced in this PR.

@kght6123
Copy link
Contributor Author

@wingkwong I've got it. thank you.

@wingkwong wingkwong changed the base branch from main to canary April 28, 2024 14:55
@wingkwong
Copy link
Member

Closing due to inactivity.

@wingkwong wingkwong closed this Sep 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] Popover not working open controll When using backdrop option on touch devie
3 participants