Skip to content

Commit

Permalink
Merge pull request #4537 from vizath/IE-polyfill-fix
Browse files Browse the repository at this point in the history
[ClickAwayListener] Add better support for IE11
  • Loading branch information
oliviertassinari committed Jun 29, 2016
2 parents 6a94615 + fb43c59 commit 6041d9c
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 9 deletions.
1 change: 1 addition & 0 deletions docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"android:setup-port": "adb reverse tcp:8081 tcp:8081"
},
"dependencies": {
"babel-polyfill": "^6.9.1",
"react-title-component": "^1.0.1",
"simple-assign": "^0.1.0"
},
Expand Down
4 changes: 1 addition & 3 deletions docs/webpack-dev-server.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const config = {
entry: [
'webpack/hot/dev-server',
'webpack/hot/only-dev-server',
'./node_modules/babel-polyfill/lib/index.js',
path.resolve(__dirname, 'src/app/app.js'),
],
// Webpack config options on how to obtain modules
Expand Down Expand Up @@ -44,9 +45,6 @@ const config = {
{from: 'src/www/index.html'},
]),
],
externals: {
fs: 'js', // To remove once https://github.com/benjamn/recast/pull/238 is released
},
module: {
// Allow loading of non-es
loaders: [
Expand Down
4 changes: 1 addition & 3 deletions docs/webpack-production.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const CopyWebpackPlugin = require('copy-webpack-plugin');
const config = {
// Entry point to the project
entry: [
'./node_modules/babel-polyfill/lib/index.js',
path.resolve(__dirname, 'src/app/app.js'),
],
// Webpack config options on how to obtain modules
Expand Down Expand Up @@ -56,9 +57,6 @@ const config = {
{from: 'src/www/versions.json'},
]),
],
externals: {
fs: 'fs', // To remove once https://github.com/benjamn/recast/pull/238 is released
},
module: {
// Allow loading of non-es5 js files.
loaders: [
Expand Down
11 changes: 8 additions & 3 deletions src/internal/ClickAwayListener.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export default class ClickAwayListener extends Component {
};

componentDidMount() {
this.isCurrentlyMounted = true;
if (this.props.onClickAway) {
bind(this.handleClickAway);
}
Expand All @@ -36,6 +37,7 @@ export default class ClickAwayListener extends Component {
}

componentWillUnmount() {
this.isCurrentlyMounted = false;
unbind(this.handleClickAway);
}

Expand All @@ -44,10 +46,13 @@ export default class ClickAwayListener extends Component {
return;
}

const el = ReactDOM.findDOMNode(this);
// IE11 support, which trigger the handleClickAway even after the unbind
if (this.isCurrentlyMounted) {
const el = ReactDOM.findDOMNode(this);

if (document.documentElement.contains(event.target) && !isDescendant(el, event.target)) {
this.props.onClickAway(event);
if (document.documentElement.contains(event.target) && !isDescendant(el, event.target)) {
this.props.onClickAway(event);
}
}
};

Expand Down

0 comments on commit 6041d9c

Please sign in to comment.