Skip to content

Commit 0cfbf3b

Browse files
Will HawkerWill Hawker
Will Hawker
authored and
Will Hawker
committed
[fixed] IE8 will now close an open DropdownButton menu when clicking 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.
1 parent 4e3a15f commit 0cfbf3b

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

Diff for: src/DropdownStateMixin.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,9 @@ const DropdownStateMixin = {
4949
handleDocumentClick(e) {
5050
// If the click originated from within this component
5151
// don't do anything.
52-
if (isNodeInRoot(e.target, React.findDOMNode(this))) {
52+
// e.srcElement is required for IE8 as e.target is undefined
53+
let target = e.target || e.srcElement;
54+
if (isNodeInRoot(target, React.findDOMNode(this))) {
5355
return;
5456
}
5557

Diff for: src/RootCloseWrapper.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,9 @@ export default class RootCloseWrapper extends React.Component {
4242

4343
handleDocumentClick(e) {
4444
// If the click originated from within this component, don't do anything.
45-
if (isNodeInRoot(e.target, React.findDOMNode(this))) {
45+
// e.srcElement is required for IE8 as e.target is undefined
46+
let target = e.target || e.srcElement;
47+
if (isNodeInRoot(target, React.findDOMNode(this))) {
4648
return;
4749
}
4850

0 commit comments

Comments
 (0)