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(dropdown): close dropdown onClickOutside #640

Closed
wants to merge 4 commits into from
Closed

fix(dropdown): close dropdown onClickOutside #640

wants to merge 4 commits into from

Conversation

Tejas9535
Copy link

@Tejas9535 Tejas9535 commented Mar 2, 2023

As a fix, I have added the functionality of auto close whenever the user clicks outside regardless of onDismissClick

fix #527

Description

Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. List any dependencies that are required for this change.

Fixes # (issue)

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change contains documentation update

Breaking changes

Please document the breaking changes if suitable.

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

  • Test A
  • Test B

Test Configuration:

  • Firmware version:
  • Hardware:
  • Toolchain:
  • SDK:

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules
  • I have checked my code and corrected any misspellings

@codecov
Copy link

codecov bot commented Mar 2, 2023

Codecov Report

Patch coverage: 100.00% and project coverage change: +0.09 🎉

Comparison is base (be78e5e) 99.42% compared to head (0109994) 99.52%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #640      +/-   ##
==========================================
+ Coverage   99.42%   99.52%   +0.09%     
==========================================
  Files         130      130              
  Lines        6440     6460      +20     
  Branches      481      491      +10     
==========================================
+ Hits         6403     6429      +26     
+ Misses         37       31       -6     
Impacted Files Coverage Δ
src/lib/components/Dropdown/Dropdown.tsx 100.00% <100.00%> (ø)
src/lib/helpers/uuid.ts 100.00% <0.00%> (+85.71%) ⬆️

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.

@rluders
Copy link
Collaborator

rluders commented Mar 2, 2023

Hi, @Tejas9535.

Thanks for your interest to work on this one, but I'm pretty sure that just changing the documentation will not fix the issue. I do recommend you check the video that I posted on the issue.

The problem is that once you click on some item at the Dropdown, it can't be closed by clicking outside of it.

I do expect that when the Dropdown has dismissOnClick={false}, and you click on a Dropdown item it doesn't close the dropdown, but if I click outside of it, it should close.

@rluders rluders changed the title fix(drop-down): close dropdown onClickOutside fix(dropdown): close dropdown onClickOutside Mar 3, 2023
@Tejas9535
Copy link
Author

Hi @rluders ,
I have Added close on outside click and also wrote Test cases for the same.
do tell me if any more changes are needed

Copy link
Collaborator

@tulup-conner tulup-conner left a comment

Choose a reason for hiding this comment

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

Thanks, mostly code style

src/lib/components/Dropdown/Dropdown.tsx Outdated Show resolved Hide resolved
src/lib/components/Dropdown/Dropdown.tsx Outdated Show resolved Hide resolved
src/lib/components/Dropdown/Dropdown.spec.tsx Show resolved Hide resolved
@tulup-conner tulup-conner added this to the 1.0.0 milestone Mar 5, 2023
As a fix I removed dismissOnClick={false} this from the Dropdown component  so it is closed
onCickOutside or when user selects one item from the dropdown

fix  #527
… false

Added Ref and wrapped whole component around it and added closeOnOutside even for dismissOnClick is
set to false so now even if dismissOnClick is set to false it'll close on outside click
formated files acording to style

#527
@rluders
Copy link
Collaborator

rluders commented Mar 8, 2023

I still have the problem, I'll try to record a video to demonstrate it 'cause it is hard to explain.

@rluders
Copy link
Collaborator

rluders commented Mar 8, 2023

I can open the dropdown and close it without any problem. However, if I click into some dropdown option and then click outside, it doesn't close, well... if I click in some specific places if closes (at the document?)... for example if I click close to the button or inside the card, it doesn't close - well, sometimes it does, but not always.

I'm using Brave, but it seems that it also happens on Firefox.

Screen.Recording.2023-03-08.at.12.04.36.mov

@tulup-conner
Copy link
Collaborator

@rluders I can't replace that on Firefox, personally. So I'm not sure what's happening, to be honest.

@rluders rluders marked this pull request as draft April 17, 2023 20:13
@rluders
Copy link
Collaborator

rluders commented Jul 6, 2023

This one was solved by #840

@rluders rluders closed this Jul 6, 2023
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.

Dropdown Menu does not close after outside click
3 participants