Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

fix: resolve dropdown menu disappearing for #11410 #11411

Merged
merged 5 commits into from
Jul 20, 2018

Conversation

arloduff
Copy link

@arloduff arloduff commented Jul 17, 2018

Description

Currently, if a dropdown menu contains an input field which displays suggestions to select from a dropdown (such as an email input on Chrome), the mouseleave event is triggered if the user hovers over one of the choices, causing the entire dropdown to disappear. This adds a check for the case of e.relatedTarget === null which will be the case when one of the input options is hovered over, but not when the mouse leaves through another event.

Motivation and Context

Allows users to choose an input option when their dropdown menu contains an input without the entire dropdown disappearing, which can be a bad user experience.

Types of changes

Dropdowns containing input fields that offer suggestions will now stay open long enough for the user to choose one. I have found one bug with this change, which is that in Firefox, if a user hovers over one of the input suggestions and then uses the keyboard to navigate to a different window, the dropdown will remain open. The dropdown will auto close again once focus is returned to the browser window, but will remain open until then. However, since current functionality is for the dropdown to disappear when one of those suggestions is hovered over, I wouldn't consider this change to break existing functionality.

  • Documentation
  • 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 change)

Checklist (all required):

  • I have read and follow the CONTRIBUTING document.
  • There are no other pull request similar to this one.
  • The pull request title is descriptive.
  • The template is fully and correctly filled.
  • The pull request targets the right branch (develop or develop-v...).
  • My commits are correctly titled and contain all relevant information.
  • My code follows the code style of this project.
  • I have updated the documentation accordingly to my changes (if relevant).
  • I have added tests to cover my changes (if relevant).
  • All new and existing tests passed.

@ncoden
Copy link
Contributor

ncoden commented Jul 17, 2018

Thank you @arloduff! I'll take a look at this.

@arloduff
Copy link
Author

Thanks @ncoden! Appreciate it!


clearTimeout($elem.data('_delay'));
$elem.data('_delay', setTimeout(function() {
// Check for hovering over input dropdown options
Copy link
Author

Choose a reason for hiding this comment

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

@ncoden It seems placing this check in the setTimeout rather than where I had it before resolves the issue of the dropdown staying open on Firefox when the user uses the keyboard to navigate to another window. The only issue I've found of it still staying open on Firefox with this change is if the user is already hovered over the input suggestions and then uses the keyboard to navigate to another window. But I wouldn't consider that a breaking change, since currently, the dropdown disappears if the user is hovered over one of those suggestions. I'm going to update the PR accordingly.

@ncoden ncoden force-pushed the fix/check-for-null-related-target branch from ec60015 to ae8fa2d Compare July 19, 2018 21:17
@ncoden
Copy link
Contributor

ncoden commented Jul 19, 2018

Hi @arloduff.

I cleaned this a bit and added some comments. I'll check if there is the same bug on others components.


// Ignore "magic mouseleave": when the mouse simply disapear from the document
// (like when entering in browser input suggestions See https://git.io/zf-11410),
// unless we actually leaved the window (and document lost focus).
Copy link
Author

Choose a reason for hiding this comment

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

Thanks 👍 I think you mean to say unless we actually left the window here, but otherwise, looks good.

Copy link
Contributor

@ncoden ncoden left a comment

Choose a reason for hiding this comment

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

LGTM. I think that some refactor is needed to correctly implement the same fix in other component. I'll do it in an other pull request.

@ncoden ncoden added this to the 6.5.0 milestone Jul 20, 2018
@ncoden ncoden merged commit 281681a into foundation:develop Jul 20, 2018
@ncoden
Copy link
Contributor

ncoden commented Jul 20, 2018

[Compatible with v6.5.0]

ncoden added a commit to ncoden/foundation-sites that referenced this pull request Aug 25, 2018
…lated-target for v6.5.0

ac88dac fix: resolve dropdown menu disappearing for foundation#11410
ae8fa2d fix: move relatedTarget null check to setTimeout for foundation#11410
a25180c style: improve dropdown hiding event readability in dropdownMenu
e46ddd1 docs: improve description of foundation#11410 bug fix in dropdownMenu
ebc4be7 docs: fix typo in bug description in dropdownMenu

Co-Authored-By: Nicolas Coden <nicolas@ncoden.fr>
Signed-off-by: Nicolas Coden <nicolas@ncoden.fr>
@ncoden ncoden mentioned this pull request Sep 10, 2018
10 tasks
# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
2 participants