From 0cfbf3be2a7b53c1a581b26ef7831388264cd2b4 Mon Sep 17 00:00:00 2001 From: Will Hawker Date: Mon, 1 Jun 2015 16:51:36 +0100 Subject: [PATCH] [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. --- src/DropdownStateMixin.js | 4 +++- src/RootCloseWrapper.js | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/DropdownStateMixin.js b/src/DropdownStateMixin.js index 586e905217..368c743c93 100644 --- a/src/DropdownStateMixin.js +++ b/src/DropdownStateMixin.js @@ -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; } diff --git a/src/RootCloseWrapper.js b/src/RootCloseWrapper.js index ac5fd7cf18..c03ea2a848 100644 --- a/src/RootCloseWrapper.js +++ b/src/RootCloseWrapper.js @@ -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; }