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(select): nullify quick clicks on select #3689

Conversation

macci001
Copy link
Contributor

@macci001 macci001 commented Aug 28, 2024

Closes #3619

📝 Description

Multiple quick clicks on select trigger was not waiting for animation to complete and starts to process the actions by subsequent clicks to open/close the popover.
The PR makes the fix which blocks the actions triggered by the click until a specific threshold time.

⛳️ Current behavior (updates)

As shown in the video below, on multiple quick click, the subsequent clicks action is triggered which closes/opens the pop-over without waiting for the animation to get completed.

Screen.Recording.2024-08-28.at.5.07.09.PM.mov

🚀 New behavior

PR adds an a delay of threshold only after which the click will trigger action.

Screen.Recording.2024-08-28.at.5.05.35.PM.mov

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

📝 Questions to the reviewers:

  • The threshold selected is based on trial and error as I was unable to get the information about timing in which the framer motion animation will get over. Current threshold works good but is there an better way in thresholding here?
  • The code makes changes in use-multiselect, by modifying the triggerProps returned. Alternative of this could be making the change in use-select by modifying onPressStart there. But the current way is implemented in order to support re-usability.

Summary by CodeRabbit

  • Bug Fixes

    • Resolved an issue with the multi-select component that caused unintended actions during rapid clicks, enhancing user experience.
  • New Features

    • Introduced a functionality to manage press event timing, preventing rapid consecutive triggers for improved interaction with the multi-select component.

Copy link

changeset-bot bot commented Aug 28, 2024

🦋 Changeset detected

Latest commit: 4bf8eab

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/use-aria-multiselect 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 Aug 28, 2024

@macci001 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 Aug 28, 2024

Walkthrough

This update implements a fix for the multi-select component in the @nextui-org/use-aria-multiselect package. It addresses an issue where rapid clicks could trigger actions before the animation for opening or closing the popover completed. A new function, useAvoidQuickPress, is introduced to manage press event timing, preventing unintended interactions during animations.

Changes

Files Change Summary
src/use-multiselect.ts Added useAvoidQuickPress function; modified useMultiSelect to integrate it.

Assessment against linked issues

Objective Addressed Explanation
Ensure actions wait for ongoing animations to complete (3619)

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.
    • @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 as 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.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

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.

@macci001 macci001 changed the title fix(select): nullify the clicks on quick presses fix(select): nullify quick clicks on select Aug 28, 2024
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

Outside diff range, codebase verification and nitpick comments (1)
.changeset/chilled-jeans-laugh.md (1)

1-5: Clarify the changeset description.

The changeset description provides a good summary of the issue and the solution. However, it could be enhanced by specifying the exact threshold time used to block the actions and mentioning the testing approach, given the trial and error method used to determine the threshold.

Consider adding these details to improve clarity and transparency for future maintainers or developers looking into this patch.

Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 4f8ae50 and a414baf.

Files selected for processing (2)
  • .changeset/chilled-jeans-laugh.md (1 hunks)
  • packages/hooks/use-aria-multiselect/src/use-multiselect.ts (3 hunks)
Additional comments not posted (1)
packages/hooks/use-aria-multiselect/src/use-multiselect.ts (1)

81-81: Ensure proper integration of useAvoidQuickPress in useMultiSelect.

The integration of useAvoidQuickPress into useMultiSelect by modifying menuTriggerProps.onPressStart is a crucial change. It's important to verify that this integration does not introduce any unintended side effects, especially in scenarios where onPressStart might be undefined or where multiple handlers might be chained.

Verify the integration by testing various scenarios where onPressStart might behave differently. Consider adding unit tests to cover these cases.

@macci001 macci001 force-pushed the macci001/add-delay-in-multi-clicks branch from a414baf to 4bf8eab Compare August 28, 2024 12:11
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

Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between a414baf and 4bf8eab.

Files selected for processing (2)
  • .changeset/chilled-jeans-laugh.md (1 hunks)
  • packages/hooks/use-aria-multiselect/src/use-multiselect.ts (3 hunks)
Files skipped from review as they are similar to previous changes (2)
  • .changeset/chilled-jeans-laugh.md
  • packages/hooks/use-aria-multiselect/src/use-multiselect.ts

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.

Storybook and NextUI doc page are using the same select component but the issue didn't happen in both case. Please explain the discrepancy between them.

@macci001
Copy link
Contributor Author

macci001 commented Aug 29, 2024

I tried to figure out the discrepant behaviour but was unable to find out what exact issue is behind this.
One thing I noted was that on docs is: While closing the select popover, the onPressStart and onPress events are not triggered (the respective events do get triggered on opening the select)
But on the story book page the onPressStart and onPress events are triggered both on opening and closing the select popover.
Edit: I have checked that the issue of quick clicks occurs in story-book, sandbox provided on docs, individual project as well, just not sure why does this not happen on the preview in docs.
@wingkwong maybe you can help in a bit here?

@wingkwong
Copy link
Member

Previously I also had a quick check but got no clue. Better identify the discrepancy to see if the fix is correct or not.

@wingkwong wingkwong assigned wingkwong and macci001 and unassigned wingkwong Aug 31, 2024
@chirokas
Copy link
Contributor

chirokas commented Sep 4, 2024

@wingkwong The issue may be caused by domRef, which does not occur in PR#3467. Additionally, the NextUI doc is outdated (When Select A is open, clicking Select B does not open Select B).

@wingkwong
Copy link
Member

@chirokas can you sync your PR with latest canary once? I think I'll move your PR to v2.4.7.

@wingkwong
Copy link
Member

Closing this one - will be handled in chirokas' PR.

@wingkwong wingkwong closed this Sep 5, 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.

[BUG] - Unexpected Behavior of Select's Animation
3 participants