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(components): Fix 'Tap to click' behavior on macOS with Edge/Chrome for Accordion and Tab #2725

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

Conversation

ericfabreu
Copy link

@ericfabreu ericfabreu commented Apr 15, 2024

📝 Description

A few components (accordion, tabs, and dropdown menu) don't seem to register a click when the user taps on them with the trackpad on macOS with the "Tap to click" option enabled on Edge and Chrome. However, a full click on the trackpad will still trigger the correct event without any issues. Tapping on Safari also works as expected.

Solution: moving the onClick definition to the mergeProps section instead of leaving it outside fixes this issue while preserving all existing functionality.

⛳️ Current behavior (updates)

Here's a quick video showing what happens when tapping on the tabs on the NextUI documentation page on Edge/Chrome. The tabs only update when I start fully clicking on the trackpad instead of tapping to click.

Screen.Recording.2024-04-12.at.7.56.06.PM.mov

🚀 New behavior

Tapping on accordions, dropdown menu items, and tabs with the trackpad on macOS now works as expected. Here's a link to a Codesandbox with these changes: codesandbox.io.

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

No

📝 Additional Information

Summary by CodeRabbit

  • Bug Fixes
    • Improved click event handling in accordion items and tabs for better functionality and performance.
    • Fixed 'Tap to click' behavior on macOS by updating event handling in relevant components.

Copy link

changeset-bot bot commented Apr 15, 2024

🦋 Changeset detected

Latest commit: 87d991e

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

This PR includes changesets to release 3 packages
Name Type
@nextui-org/accordion Patch
@nextui-org/tabs 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 Apr 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 Apr 22, 2024 5:27pm

Copy link

vercel bot commented Apr 15, 2024

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

coderabbitai bot commented Apr 15, 2024

Walkthrough

The updates focus on refining the onClick event handling across different components (Accordion, Menu, and Tabs) to improve functionality and user interaction consistency, particularly with trackpad operations like tapping.

Changes

File Path Change Summary
.../accordion/src/use-accordion-item.ts Adjusted onClick property handling to ensure proper event chaining for macOS tap-to-click behavior.
.../menu/src/use-menu-item.ts Updated onClick property handling for macOS tap-to-click behavior consistency.
.../tabs/src/tab.tsx Enhanced onClick event logic to address macOS tap-to-click issues for the Tabs component.

Assessment against linked issues

Objective Addressed Explanation
Ensure Tabs component responds to tap-to-click on macOS touchpad (#1538)
Resolve inconsistent click vs tap behavior across components on macOS (#2606) Changes may impact behavior but specific to Tabs, not general components.

Recent Review Details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits Files that changed from the base of the PR and between 67a97c9 and 87d991e.
Files selected for processing (1)
  • .changeset/slimy-ways-repair.md (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • .changeset/slimy-ways-repair.md

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.

@ericfabreu ericfabreu changed the title fix(components): Fix 'Tap to click' behavior on macOS for Accordion, Tab, and Dropdown fix(components): Fix 'Tap to click' behavior on macOS with Edge/Chrome for Accordion, Tab, and Dropdown Apr 15, 2024
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.

Thanks for the PR. Please include the changeset file.

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

.changeset/slimy-ways-repair.md Outdated Show resolved Hide resolved
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.

please sync with main once. I think some code has been outdated.

@Ad-Mora
Copy link

Ad-Mora commented Apr 22, 2024

Can this fix be extended to the Switch component? Same issue is occurring there

@ericfabreu ericfabreu changed the title fix(components): Fix 'Tap to click' behavior on macOS with Edge/Chrome for Accordion, Tab, and Dropdown fix(components): Fix 'Tap to click' behavior on macOS with Edge/Chrome for Accordion and Tab Apr 22, 2024
@ericfabreu
Copy link
Author

Can this fix be extended to the Switch component? Same issue is occurring there

Would that be issue #2765? I haven't been able to reproduce it on my MacBook, unfortunately. Tapping or clicking on the slider on Chrome, Edge, and Safari works correctly for me. Would you happen to have any repro steps?

@Ad-Mora
Copy link

Ad-Mora commented Apr 22, 2024

Would that be issue #2765? I haven't been able to reproduce it on my MacBook, unfortunately. Tapping or clicking on the slider on Chrome, Edge, and Safari works correctly for me. Would you happen to have any repro steps?

I just tried reproducing, and the issue no longer appears - how embarrassing. Previously, it was having the same behavior that the Tab component was, where the component was only sporadically registering the clicking from the Mac touchpad. But given that I can't reproduce the issue anymore, we can call this moot.

@ha-sante
Copy link

+1 - I get this issue on arc browser and its not just in my app itself.
Even on the nextui website (code / preview) buttons.

Thought this was a mistake or some plugin i use.

Another note is that when i click on the tab option multiple times - somehow it finally picks it up and shows the code preview.

So as though am not contributing much to this solution - i share that its a big issue - at least for me.

Thanks for all your hardwork.

@wingkwong wingkwong changed the base branch from main to canary April 28, 2024 14:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
5 participants