Skip to content

Commit

Permalink
Fixes #3887 issue with clicking element removed from DOM inside popup
Browse files Browse the repository at this point in the history
  • Loading branch information
jlukic committed Apr 1, 2016
1 parent 0c3c410 commit b155731
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
2 changes: 2 additions & 0 deletions RELEASE-NOTES.md
Expand Up @@ -12,6 +12,8 @@
- **Modules** - Added new setting `silent` to all modules which allows you to disable **all** console output including errors. This can be useful for preventing known errors, like a popup which cannot place itself on screen, or `sticky` content which initializes before it is visible #3713
- **Dropdown** - All dropdowns, not just `selection dropdown`, will now select the first `menu item` that starts with a pressed keyboard key, for example "N" will select "New"
- **Build Tools** - Added new `autoInstall` option to allow for Semantic to be installed without user interaction. See [docs explanation](http://www.semantic-ui.com/introduction/advanced-usage.html#Auto-Install) for how to use. #3616 **Thanks @algorithme**
- **Popup** - Fixed issue where clicking element inside popup removed from DOM (like clicking a multi select label) would cause popup to close #3887


**Critical Bugs**
- **All UI** - Using `setting` on a setting that is an object literal, for example `error: {}` will now extend the existing object instead of replacing it.
Expand Down
13 changes: 9 additions & 4 deletions src/definitions/modules/popup.js
Expand Up @@ -189,13 +189,18 @@ $.fn.popup = function(parameters) {
}
},
hideGracefully: function(event) {
let
$target = $(event.target),
isInDOM = $.contains(document.documentElement, event.target),
inPopup = ($target.closest(selector.popup).length > 0)
;
// don't close on clicks inside popup
if(event && $(event.target).closest(selector.popup).length === 0) {
module.debug('Click occurred outside popup hiding popup');
module.hide();
if(event && (!isInDOM || inPopup)) {
module.debug('Click was inside popup, keeping popup open');
}
else {
module.debug('Click was inside popup, keeping popup open');
module.debug('Click occurred outside popup hiding popup');
module.hide();
}
}
},
Expand Down

0 comments on commit b155731

Please sign in to comment.