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: Solves component paginatedMultiSelectFiltered dropdown close issue #1262

Conversation

Spiral-Memory
Copy link

@Spiral-Memory Spiral-Memory commented Jan 10, 2024

Proposed changes (including videos or screenshots)

I've implemented an handleOnMouseDown function to manage the visibility of the dropdown menu. This handler also ensures that the dropdown remains unaffected when removing chip items by checking whether the mouseDown event occurred on the Chip component.

For the Anchor component, the onClick prop has been removed, and a custom function, handleBlur, is now assigned to onBlur prop. This function is responsible for hiding the dropdown only when necessary.

To maintain a proper sequence of actions, focusing on the box/anchor is handled separately by the handleClick function assigned as onClick prop

The order of actions is as follows: onMouseDown first, followed by onBlur, and finally onClick.

2024-01-11.13-07-28.mp4

Issue(s)

Closes #1261

Further comments

The problem happened because the onBlur event, which hides the dropdown when you click outside, runs before the onClick event. So, if you click inside the box, like on the arrow icon, the onBlur event hides the dropdown, and then the onClick event thinks it's hidden and shows it again.

To fix this, I used the onMouseDown event to handle these situations better. Another way is to delay the onBlur function using setTimeout by 100-200ms. This makes sure onBlur only happens after the click is done. I felt the first solution was better, but here's the setTimeout code in case you want to consider it.

    const handleBlur = useEffectEvent(() => {
    // Use setTimeout to allow time for the click event to be processed first
    setTimeout(() => {
      if (visible === AnimatedVisibility.VISIBLE) {
        hide();
      }
    }, 150);
  });

Copy link

changeset-bot bot commented Jan 10, 2024

⚠️ No Changeset found

Latest commit: 4989abc

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@CLAassistant
Copy link

CLAassistant commented Jan 10, 2024

CLA assistant check
All committers have signed the CLA.

@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@Spiral-Memory Spiral-Memory force-pushed the fix/paginatedmultiselect-dropdown-close-issue branch from b216a83 to 4989abc Compare February 17, 2024 19:04
@dougfabris
Copy link
Member

Hi there, thanks for the contribution! 🚀 💯

We're planning an entire replacement of all the components related to AutoComplete and all the Select components since we're focusing a lot on accessibility. Trying to maintain it became a nightmare, and because of that we're not going to accept any contributions related to these components at this time.


Questions? Help needed? Feature Requests?

  • Join our Open Server in the #support channel and feel free to raise a question
  • Join our Community Forum and search/create a post there

@dougfabris dougfabris closed this Feb 27, 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
3 participants