Skip to content

Commit

Permalink
Add click outside toggling to block switcher menu. (#596)
Browse files Browse the repository at this point in the history
  • Loading branch information
BE-Webdesign authored and nylen committed May 2, 2017
1 parent 6344d46 commit 734e188
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
11 changes: 10 additions & 1 deletion editor/components/block-switcher/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
*/
import { connect } from 'react-redux';
import { uniq, get, reduce } from 'lodash';
import clickOutside from 'react-click-outside';

/**
* Internal dependencies
Expand All @@ -19,6 +20,14 @@ class BlockSwitcher extends wp.element.Component {
};
}

handleClickOutside() {
if ( ! this.state.open ) {
return;
}

this.toggleMenu();
}

toggleMenu() {
this.setState( {
open: ! this.state.open
Expand Down Expand Up @@ -94,4 +103,4 @@ export default connect(
} );
}
} )
)( BlockSwitcher );
)( clickOutside( BlockSwitcher ) );
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
"lodash": "^4.17.4",
"react": "^15.5.4",
"react-autosize-textarea": "^0.4.2",
"react-click-outside": "^2.3.0",
"react-dom": "^15.5.4",
"react-redux": "^5.0.4",
"react-slot-fill": "^1.0.0-alpha.11",
Expand Down

0 comments on commit 734e188

Please sign in to comment.