Skip to content

Commit

Permalink
[fixed] IE8 will now close an open DropdownButton menu when clicking …
Browse files Browse the repository at this point in the history
…button

This commit fixes an Internet Explorer 8 bug where attempting to close a button dropdown menu, by clicking the button itself, would not close the menu.
Event.target is undefined in IE8, so `isNodeInRoot(e.target, React.findDOMNode(this))` would return false, allowing the click event to bubble up to the document and re-open the menu.
  • Loading branch information
Will Hawker authored and Will Hawker committed Jun 1, 2015
1 parent 4e3a15f commit 0cfbf3b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/DropdownStateMixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,9 @@ const DropdownStateMixin = {
handleDocumentClick(e) {
// If the click originated from within this component
// don't do anything.
if (isNodeInRoot(e.target, React.findDOMNode(this))) {
// e.srcElement is required for IE8 as e.target is undefined
let target = e.target || e.srcElement;
if (isNodeInRoot(target, React.findDOMNode(this))) {
return;
}

Expand Down
4 changes: 3 additions & 1 deletion src/RootCloseWrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@ export default class RootCloseWrapper extends React.Component {

handleDocumentClick(e) {
// If the click originated from within this component, don't do anything.
if (isNodeInRoot(e.target, React.findDOMNode(this))) {
// e.srcElement is required for IE8 as e.target is undefined
let target = e.target || e.srcElement;
if (isNodeInRoot(target, React.findDOMNode(this))) {
return;
}

Expand Down

0 comments on commit 0cfbf3b

Please sign in to comment.