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

THEOC-1722: Update dropdown to not close unless clicking outside #322

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

Conversation

JessicaTatham
Copy link

@JessicaTatham JessicaTatham commented Jan 25, 2021

Dropdown doesn't close unless clicking outside of ref zone. Also expose isOpen as updatedIsOpen to allow component to control if we want alternative functionality.

Screen Shot 2021-01-26 at 12 20 25 PM

How Has This Been Tested?

Types of changes

  • New feature (non-breaking change which adds functionality)
  • Improvement (non-breaking change which improves functionality or refactors code)
  • Bug fix (non-breaking change which fixes an issue)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

@JessicaTatham JessicaTatham self-assigned this Jan 25, 2021
Copy link
Contributor

@jsteinb jsteinb left a comment

Choose a reason for hiding this comment

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

This seems like it fixes the issue. But I don't really get the use case for the controlledIsOpen prop, and the naming of it seems confusing. And this is changing the default behavior of the Dropdown so could be changing the behavior of anything that uses the Dropdown. Not sure if anything relied on the behavior as it was but we might want to keep the same defaults and override it in the place where you're using this?

<StyledMenu width={width} data-qaid={`${qaId}-flyout`}>
<StyledMenu
width={width}
ref={menuRef}
Copy link
Contributor

@jsteinb jsteinb Jan 26, 2021

Choose a reason for hiding this comment

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

do we also need to add the menuRef in the case where flyoutContainer == false? I get kind of unexpected behavior in your storybook story where flyoutContainer={false} when keepOpenOnClick is true, because it's passing menuRef into the useOutsideClick but not rendering any element with ref={menuRef}. Might be able to just do this on line 105:

<div ref={menuRef}>
  {children}
</div>

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