File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 127127 "prop-types" : " ^15.5.10" ,
128128 "qs" : " ^6.1.0" ,
129129 "react" : " ^15.4.1" ,
130+ "react-click-outside" : " tj/react-click-outside" ,
130131 "react-copy-to-clipboard" : " ^5.0.0" ,
131132 "react-dom" : " ^15.4.1" ,
132133 "react-draggable" : " ^2.2.6" ,
Original file line number Diff line number Diff line change @@ -34,6 +34,7 @@ import {
3434 popOutProject ,
3535 toggleEditorTextSize ,
3636 toggleTopBarMenu ,
37+ closeTopBarMenu ,
3738} from './ui' ;
3839
3940import {
@@ -77,4 +78,5 @@ export {
7778 repoExportNotDisplayed ,
7879 toggleEditorTextSize ,
7980 toggleTopBarMenu ,
81+ closeTopBarMenu ,
8082} ;
Original file line number Diff line number Diff line change @@ -59,3 +59,7 @@ export const toggleEditorTextSize = createAction(
5959export const toggleTopBarMenu = createAction (
6060 'TOGGLE_TOP_BAR_MENU' ,
6161) ;
62+
63+ export const closeTopBarMenu = createAction (
64+ 'CLOSE_TOP_BAR_MENU' ,
65+ ) ;
Original file line number Diff line number Diff line change @@ -4,7 +4,7 @@ import ErrorReport from '../containers/ErrorReport';
44import Preview from '../containers/Preview' ;
55
66export default function Output ( {
7- isDraggingColumnDivider ,
7+ ignorePointerEvents ,
88 style,
99 onRef,
1010} ) {
@@ -13,7 +13,7 @@ export default function Output({
1313 className = "environment__column"
1414 ref = { onRef }
1515 style = { Object . assign ( { } , style , {
16- pointerEvents : isDraggingColumnDivider ? 'none' : 'all' ,
16+ pointerEvents : ignorePointerEvents ? 'none' : 'all' ,
1717 } ) }
1818 >
1919 < div className = "environment__columnContents output" >
@@ -25,7 +25,7 @@ export default function Output({
2525}
2626
2727Output . propTypes = {
28- isDraggingColumnDivider : PropTypes . bool . isRequired ,
28+ ignorePointerEvents : PropTypes . bool . isRequired ,
2929 style : PropTypes . object . isRequired ,
3030 onRef : PropTypes . func . isRequired ,
3131} ;
Original file line number Diff line number Diff line change @@ -8,6 +8,7 @@ export default function CurrentUser({
88 isOpen,
99 user,
1010 onClick,
11+ onClose,
1112 onLogOut,
1213 onStartLogIn,
1314} ) {
@@ -31,7 +32,11 @@ export default function CurrentUser({
3132 < span className = "top-bar__drop-down-button u__icon" >
3233 
3334 </ span >
34- < CurrentUserMenu isOpen = { isOpen } onLogOut = { onLogOut } />
35+ < CurrentUserMenu
36+ isOpen = { isOpen }
37+ onClose = { onClose }
38+ onLogOut = { onLogOut }
39+ />
3540 </ div >
3641 ) ;
3742 }
@@ -53,6 +58,7 @@ CurrentUser.propTypes = {
5358 authenticated : PropTypes . boolean ,
5459 } ) . isRequired ,
5560 onClick : PropTypes . func . isRequired ,
61+ onClose : PropTypes . func . isRequired ,
5662 onLogOut : PropTypes . func . isRequired ,
5763 onStartLogIn : PropTypes . func . isRequired ,
5864} ;
Original file line number Diff line number Diff line change 1- import React from 'react' ;
1+ import ClickOutside from 'react-click-outside ' ;
22import PropTypes from 'prop-types' ;
3+ import React from 'react' ;
34import { t } from 'i18next' ;
45
5- export default function CurrentUserMenu ( { isOpen, onLogOut} ) {
6+ export default function CurrentUserMenu ( { isOpen, onClose , onLogOut} ) {
67 if ( ! isOpen ) {
78 return null ;
89 }
910
1011 return (
11- < div className = "top-bar__menu" >
12- < div className = "top-bar__menu-item" onClick = { onLogOut } >
13- { t ( 'top-bar.session.log-out-prompt' ) }
12+ < ClickOutside onClickOutside = { onClose } >
13+ < div className = "top-bar__menu" >
14+ < div className = "top-bar__menu-item" onClick = { onLogOut } >
15+ { t ( 'top-bar.session.log-out-prompt' ) }
16+ </ div >
1417 </ div >
15- </ div >
18+ </ ClickOutside >
1619 ) ;
1720}
1821
1922CurrentUserMenu . propTypes = {
2023 isOpen : PropTypes . bool . isRequired ,
24+ onClose : PropTypes . func . isRequired ,
2125 onLogOut : PropTypes . func . isRequired ,
2226} ;
Original file line number Diff line number Diff line change @@ -39,6 +39,7 @@ export default function TopBar({
3939 projectKeys,
4040 validationState,
4141 onClickMenu,
42+ onCloseMenu,
4243 onCreateNewProject,
4344 onCreateSnapshot,
4445 onExportGist,
@@ -92,6 +93,7 @@ export default function TopBar({
9293 isOpen = { openMenu === 'currentUser' }
9394 user = { currentUser }
9495 onClick = { partial ( onClickMenu , 'currentUser' ) }
96+ onClose = { partial ( onCloseMenu , 'currentUser' ) }
9597 onLogOut = { onLogOut }
9698 onStartLogIn = { onStartLogIn }
9799 />
@@ -113,6 +115,7 @@ TopBar.propTypes = {
113115 projectKeys : PropTypes . arrayOf ( PropTypes . string ) . isRequired ,
114116 validationState : PropTypes . string . isRequired ,
115117 onClickMenu : PropTypes . func . isRequired ,
118+ onCloseMenu : PropTypes . func . isRequired ,
116119 onCreateNewProject : PropTypes . func . isRequired ,
117120 onCreateSnapshot : PropTypes . func . isRequired ,
118121 onExportGist : PropTypes . func . isRequired ,
Original file line number Diff line number Diff line change @@ -180,7 +180,10 @@ class Workspace extends React.Component {
180180 const { isDraggingColumnDivider, rowsFlex} = this . props ;
181181 return (
182182 < Output
183- isDraggingColumnDivider = { isDraggingColumnDivider }
183+ ignorePointerEvents = {
184+ isDraggingColumnDivider ||
185+ Boolean ( get ( this , 'props.ui.topBar.openMenu' ) )
186+ }
184187 style = { { flex : rowsFlex [ 1 ] } }
185188 onRef = { partial ( this . _storeColumnRef , 1 ) }
186189 />
Original file line number Diff line number Diff line change @@ -18,6 +18,7 @@ import {
1818 isUserTyping ,
1919} from '../selectors' ;
2020import {
21+ closeTopBarMenu ,
2122 createProject ,
2223 createSnapshot ,
2324 exportGist ,
@@ -55,6 +56,10 @@ function mapDispatchToProps(dispatch) {
5556 dispatch ( toggleTopBarMenu ( menuKey ) ) ;
5657 } ,
5758
59+ onCloseMenu ( menuKey ) {
60+ dispatch ( closeTopBarMenu ( menuKey ) ) ;
61+ } ,
62+
5863 onCreateNewProject ( ) {
5964 dispatch ( createProject ( ) ) ;
6065 } ,
Original file line number Diff line number Diff line change @@ -190,6 +190,12 @@ export default function ui(stateIn, action) {
190190 menu => menu === action . payload ? null : action . payload ,
191191 ) ;
192192
193+ case 'CLOSE_TOP_BAR_MENU' :
194+ return state . updateIn (
195+ [ 'topBar' , 'openMenu' ] ,
196+ menu => menu === action . payload ? null : menu ,
197+ ) ;
198+
193199 default :
194200 return state ;
195201 }
You can’t perform that action at this time.
0 commit comments