@@ -40,7 +40,7 @@ function getOrCreateContainer() {
40
40
return container ;
41
41
}
42
42
43
- class ContextualMenu extends React . Component {
43
+ export default class ContextualMenu extends React . Component {
44
44
propTypes : {
45
45
top : PropTypes . number ,
46
46
bottom : PropTypes . number ,
@@ -57,6 +57,10 @@ class ContextualMenu extends React.Component {
57
57
menuPaddingRight : PropTypes . number ,
58
58
menuPaddingBottom : PropTypes . number ,
59
59
menuPaddingLeft : PropTypes . number ,
60
+
61
+ // If true, insert an invisible screen-sized element behind the
62
+ // menu that when clicked will close it.
63
+ hasBackground : PropTypes . bool ,
60
64
}
61
65
62
66
render ( ) {
@@ -154,31 +158,30 @@ class ContextualMenu extends React.Component {
154
158
{ chevron }
155
159
< ElementClass { ...props } onFinished = { props . closeMenu } onResize = { props . windowResize } />
156
160
</ div >
157
- < div className = "mx_ContextualMenu_background" onClick = { props . closeMenu } > </ div >
161
+ { props . hasBackground && < div className = "mx_ContextualMenu_background" onClick = { props . closeMenu } > </ div > }
158
162
< style > { chevronCSS } </ style >
159
163
</ div > ;
160
164
}
161
165
}
162
166
163
- module . exports = {
164
- createMenu : function ( ElementClass , props ) {
165
- const closeMenu = function ( ...args ) {
166
- ReactDOM . unmountComponentAtNode ( getOrCreateContainer ( ) ) ;
167
+ export function createMenu ( ElementClass , props ) {
168
+ const closeMenu = function ( ...args ) {
169
+ ReactDOM . unmountComponentAtNode ( getOrCreateContainer ( ) ) ;
167
170
168
- if ( props && props . onFinished ) {
169
- props . onFinished . apply ( null , args ) ;
170
- }
171
- } ;
171
+ if ( props && props . onFinished ) {
172
+ props . onFinished . apply ( null , args ) ;
173
+ }
174
+ } ;
172
175
173
- const menu = < ContextualMenu
174
- { ...props }
175
- elementClass = { ElementClass }
176
- closeMenu = { closeMenu }
177
- windowResize = { closeMenu }
178
- /> ;
176
+ const menu = < ContextualMenu
177
+ { ...props }
178
+ hasBackground = { true }
179
+ elementClass = { ElementClass }
180
+ closeMenu = { closeMenu }
181
+ windowResize = { closeMenu }
182
+ /> ;
179
183
180
- ReactDOM . render ( menu , getOrCreateContainer ( ) ) ;
184
+ ReactDOM . render ( menu , getOrCreateContainer ( ) ) ;
181
185
182
- return { close : closeMenu } ;
183
- } ,
184
- } ;
186
+ return { close : closeMenu } ;
187
+ }
0 commit comments