diff --git a/RELEASE-NOTES.md b/RELEASE-NOTES.md index 8de4bbfd4..d4d1b1910 100644 --- a/RELEASE-NOTES.md +++ b/RELEASE-NOTES.md @@ -4,6 +4,7 @@ **Bugs** - **Search** - Fixed issue where pressing "up" key when no results selected would cause bottom result to be selected +- **Search** - Fixed issue where input may attempt to refocus when element is immediately removed from browser's DOM after a result is clicked **Enhancements** - **Checkbox** - Adds additional variables for styling toggle checkbox on/off state diff --git a/src/definitions/modules/search.js b/src/definitions/modules/search.js index 12ecb5597..cf5c84ad1 100644 --- a/src/definitions/modules/search.js +++ b/src/definitions/modules/search.js @@ -366,7 +366,14 @@ $.fn.search = function(parameters) { return $results.hasClass(className.hidden); }, inMessage: function(event) { - return (event.target && $(event.target).closest(selector.message).length > 0); + if(!event.target) { + return; + } + var + $target = $(event.target), + isInDOM = $.contains(document.documentElement, event.target) + ; + return (isInDOM && $target.closest(selector.message).length > 0); }, empty: function() { return ($results.html() === '');