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

Add events to ClayDropdown to close on mobile and when the esq is pressed and when the iframe is clicked #959

Merged
merged 4 commits into from
May 31, 2018

Conversation

matuzalemsteles
Copy link
Member

I've been working on looking at the best approach to close the dropdown when it has a click on the iframe.

Approach 1

We could listen to the click events of some iframe element on the screen, but we would have problems with some use cases:

  • We do not know when there will be an iframe on screen (Modal case)
  • The click event will only work if the iframe domain is the same as the navigation

Approach 2

We could go with the simpler approach of closing the dropdown when clicking on some dropdown item but we can not due to interactions in the dropdown.

Approach 3

We can listen to the blur event in window and check the activeElement if it is an iframe so we can close the dropdown.

I'm following with the 3 approach to cover use cases.

NOTE: I ended up changing the way we are attaching the events, instead of adding them when created, is only adding when the dropdown is open, since it only becomes necessary at that moment. It helps in the case of when we have too many dropdowns on the screen not to be listening to events unnecessarily.

@coveralls
Copy link

Pull Request Test Coverage Report for Build 866

  • 3 of 9 (33.33%) changed or added relevant lines in 1 file are covered.
  • 4 unchanged lines in 1 file lost coverage.
  • Overall coverage decreased (-0.2%) to 81.207%

Changes Missing Coverage Covered Lines Changed/Added Lines %
packages/clay-dropdown/src/ClayDropdownBase.js 3 9 33.33%
Files with Coverage Reduction New Missed Lines %
packages/clay-dropdown/src/ClayDropdownBase.js 4 62.5%
Totals Coverage Status
Change from base Build 865: -0.2%
Covered Lines: 5067
Relevant Lines: 5418

💛 - Coveralls

@carloslancha
Copy link
Contributor

Just started reviewing :)

:octocat: Sent from GH.

@carloslancha
Copy link
Contributor

@matuzalemsteles I'm merging this but there's an issue we need to resolve when we have time. On mobile if you open the dropdown and click and drag outside, the dropdown shouldn't close and now it does.

http://recordit.co/xXAKUaBToj

@carloslancha carloslancha merged commit 2401c61 into liferay:develop May 31, 2018
@matuzalemsteles
Copy link
Member Author

Ah yeah, Good observation. Thanks @carloslancha!

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.

3 participants