mirror of
https://github.com/captbaritone/webamp.git
synced 2026-07-21 09:09:01 +00:00
Fix close context menu on click outside menu
This commit is contained in:
parent
5444f5348a
commit
150fc677da
1 changed files with 8 additions and 3 deletions
|
|
@ -18,7 +18,7 @@ const SKINS = [
|
|||
];
|
||||
|
||||
class ContextMenu extends React.Component {
|
||||
componantWillMount() {
|
||||
componentWillMount() {
|
||||
// Clicking anywhere outside the context menu will close the window
|
||||
document.addEventListener("click", this.props.closeMenu);
|
||||
}
|
||||
|
|
@ -75,10 +75,15 @@ class ContextMenu extends React.Component {
|
|||
const mapStateToProps = state => state.contextMenu;
|
||||
const mapDispatchToProps = (dispatch, ownProps) => ({
|
||||
close: () => dispatch(close()),
|
||||
closeMenu: () => dispatch({ type: CLOSE_CONTEXT_MENU }),
|
||||
closeMenu: () => {
|
||||
console.log("close");
|
||||
dispatch({ type: CLOSE_CONTEXT_MENU });
|
||||
},
|
||||
toggleMenu: e => {
|
||||
dispatch({ type: TOGGLE_CONTEXT_MENU });
|
||||
e.stopPropagation();
|
||||
// TODO: Consider binding to a ref instead.
|
||||
// https://stackoverflow.com/a/24421834
|
||||
e.nativeEvent.stopImmediatePropagation();
|
||||
},
|
||||
openFileDialog: () => dispatch(openFileDialog(ownProps.fileInput)),
|
||||
setSkin: filename => dispatch(setSkinFromFilename(filename))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue