From 9d0924f722d52a376e6a7e3493d0f7198ff98c1b Mon Sep 17 00:00:00 2001 From: Devin Howard Date: Sat, 25 Feb 2017 15:24:04 -0800 Subject: [PATCH] close permission selector when you click outside --- frontend/src/components/TopicCard/Permission.js | 10 +++++++--- package.json | 1 + 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/frontend/src/components/TopicCard/Permission.js b/frontend/src/components/TopicCard/Permission.js index c3e78fb1..bceb2d4c 100644 --- a/frontend/src/components/TopicCard/Permission.js +++ b/frontend/src/components/TopicCard/Permission.js @@ -1,7 +1,7 @@ import React, { PropTypes, Component } from 'react' -// TODO how do we make it so that clicking elsewhere on the topic -// card cancels this +import onClickOutsideAddon from 'react-onclickoutside' + class Permission extends Component { constructor(props) { super(props) @@ -22,6 +22,10 @@ class Permission extends Component { this.setState({selectingPermission: false}) } + handleClickOutside = instance => { + this.closePermissionSelect() + } + liClick = value => event => { this.closePermissionSelect() this.props.updateTopic({ @@ -62,4 +66,4 @@ Permission.propTypes = { updateTopic: PropTypes.func } -export default Permission +export default onClickOutsideAddon(Permission) diff --git a/package.json b/package.json index 3dbc40df..6db62390 100644 --- a/package.json +++ b/package.json @@ -45,6 +45,7 @@ "react": "15.4.2", "react-dom": "15.4.2", "react-dropzone": "3.9.1", + "react-onclickoutside": "^5.9.0", "redux": "3.6.0", "riek": "^1.0.7", "simplewebrtc": "2.2.2",