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: Prevent dropdowns from closing when elements inside self-dismiss #541

Merged
merged 1 commit into from
Dec 1, 2022

Conversation

just-boris
Copy link
Member

Description

If an element inside dropdown dismisses itself after click, the click away listener detects it as a click outside. To prevent this from happening, moved the listener to capture phase. setTimeout are also not needed anymore, because it was only to work around bubbling issues, which are not happening when using capture

Found when integrating feature #531 in the real use case

How has this been tested?

Added an extra unit test

Review checklist

The following items are to be evaluated by the author(s) and the reviewer(s).

Correctness

  • Changes include appropriate documentation updates.
  • Changes are backward-compatible if not indicated, see CONTRIBUTING.md.
  • Changes do not include unsupported browser features, see CONTRIBUTING.md.
  • Changes were manually tested for accessibility, see accessibility guidelines.

Security

Testing

  • Changes are covered with new/existing unit tests?
  • Changes are covered with new/existing integration tests?

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@codecov
Copy link

codecov bot commented Nov 30, 2022

Codecov Report

Base: 92.38% // Head: 92.39% // Increases project coverage by +0.01% 🎉

Coverage data is based on head (22414c0) compared to base (d10dba7).
Patch coverage: 100.00% of modified lines in pull request are covered.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #541      +/-   ##
==========================================
+ Coverage   92.38%   92.39%   +0.01%     
==========================================
  Files         569      569              
  Lines       16218    16216       -2     
  Branches     4433     4433              
==========================================
  Hits        14983    14983              
+ Misses       1151     1149       -2     
  Partials       84       84              
Impacted Files Coverage Δ
src/internal/components/dropdown/index.tsx 92.30% <100.00%> (-0.09%) ⬇️
src/date-range-picker/index.tsx 99.03% <0.00%> (+0.96%) ⬆️
src/button-dropdown/internal.tsx 100.00% <0.00%> (+1.38%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@just-boris just-boris marked this pull request as ready for review November 30, 2022 21:35
@just-boris just-boris requested a review from a team as a code owner November 30, 2022 21:35
@just-boris just-boris requested review from pan-kot and removed request for a team November 30, 2022 21:35
Copy link
Member

@pan-kot pan-kot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

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