11let React = require ( 'react' ) ;
22let StylePropable = require ( './mixins/style-propable' ) ;
33let Transitions = require ( './styles/transitions' ) ;
4- let ClickAwayable = require ( './mixins/click-awayable' ) ;
54let KeyCode = require ( './utils/key-code' ) ;
65let DropDownArrow = require ( './svg-icons/navigation/arrow-drop-down' ) ;
76let Paper = require ( './paper' ) ;
@@ -11,7 +10,7 @@ let ClearFix = require('./clearfix');
1110
1211let DropDownMenu = React . createClass ( {
1312
14- mixins : [ StylePropable , ClickAwayable ] ,
13+ mixins : [ StylePropable ] ,
1514
1615 contextTypes : {
1716 muiTheme : React . PropTypes . object ,
@@ -37,8 +36,8 @@ let DropDownMenu = React.createClass({
3736 getDefaultProps ( ) {
3837 return {
3938 autoWidth : true ,
40- valueMember :'payload' ,
41- displayMember :'text' ,
39+ valueMember : 'payload' ,
40+ displayMember : 'text' ,
4241 } ;
4342 } ,
4443
@@ -51,10 +50,6 @@ let DropDownMenu = React.createClass({
5150 } ;
5251 } ,
5352
54- componentClickAway ( ) {
55- this . setState ( { open :false } ) ;
56- } ,
57-
5853 componentDidMount ( ) {
5954 if ( this . props . autoWidth ) this . _setWidth ( ) ;
6055 if ( this . props . hasOwnProperty ( 'selectedIndex' ) ) this . _setSelectedIndex ( this . props ) ;
@@ -70,25 +65,19 @@ let DropDownMenu = React.createClass({
7065 }
7166 } ,
7267
73- getSpacing ( ) {
74- return this . context . muiTheme . spacing ;
75- } ,
76-
77- getTextColor ( ) {
78- return this . context . muiTheme . palette . textColor ;
79- } ,
80-
8168 getStyles ( ) {
69+ let zIndex = 5 ; // As AppBar
70+ let spacing = this . context . muiTheme . spacing ;
8271 let accentColor = this . context . muiTheme . component . dropDownMenu . accentColor ;
8372 let backgroundColor = this . context . muiTheme . component . menu . backgroundColor ;
8473 let styles = {
8574 root : {
8675 transition : Transitions . easeOut ( ) ,
8776 position : 'relative' ,
8877 display : 'inline-block' ,
89- height : this . getSpacing ( ) . desktopSubheaderHeight ,
90- fontSize : this . getSpacing ( ) . desktopDropDownMenuFontSize ,
91- outline :'none' ,
78+ height : spacing . desktopSubheaderHeight ,
79+ fontSize : spacing . desktopDropDownMenuFontSize ,
80+ outline : 'none' ,
9281 } ,
9382 control : {
9483 cursor : 'pointer' ,
@@ -100,41 +89,52 @@ let DropDownMenu = React.createClass({
10089 backgroundColor : backgroundColor ,
10190 height : '100%' ,
10291 width : '100%' ,
103- opacity :0 ,
92+ opacity : 0 ,
10493 } ,
10594 icon : {
10695 position : 'absolute' ,
107- top : ( ( this . getSpacing ( ) . desktopToolbarHeight - 24 ) / 2 ) ,
108- right : this . getSpacing ( ) . desktopGutterLess ,
96+ top : ( ( spacing . desktopToolbarHeight - 24 ) / 2 ) ,
97+ right : spacing . desktopGutterLess ,
10998 fill : this . context . muiTheme . component . dropDownMenu . accentColor ,
11099 } ,
111100 label : {
112101 transition : Transitions . easeOut ( ) ,
113- lineHeight : this . getSpacing ( ) . desktopToolbarHeight + 'px' ,
102+ lineHeight : spacing . desktopToolbarHeight + 'px' ,
114103 position : 'absolute' ,
115- paddingLeft : this . getSpacing ( ) . desktopGutter ,
104+ paddingLeft : spacing . desktopGutter ,
116105 top : 0 ,
117106 opacity : 1 ,
118- color : this . getTextColor ( ) ,
107+ color : this . context . muiTheme . palette . textColor ,
119108 } ,
120109 underline : {
121110 borderTop : 'solid 1px ' + accentColor ,
122- margin : '-1px ' + this . getSpacing ( ) . desktopGutter + 'px' ,
111+ margin : '-1px ' + spacing . desktopGutter + 'px' ,
112+ } ,
113+ menu : {
114+ zIndex : zIndex + 1 ,
123115 } ,
124116 menuItem : {
125- paddingRight : this . getSpacing ( ) . iconSize +
126- this . getSpacing ( ) . desktopGutterLess +
127- this . getSpacing ( ) . desktopGutterMini ,
128- height : this . getSpacing ( ) . desktopDropDownMenuItemHeight ,
129- lineHeight : this . getSpacing ( ) . desktopDropDownMenuItemHeight + 'px' ,
117+ paddingRight : spacing . iconSize +
118+ spacing . desktopGutterLess +
119+ spacing . desktopGutterMini ,
120+ height : spacing . desktopDropDownMenuItemHeight ,
121+ lineHeight : spacing . desktopDropDownMenuItemHeight + 'px' ,
130122 whiteSpace : 'nowrap' ,
131123 } ,
132124 rootWhenOpen : {
133125 opacity : 1 ,
134126 } ,
135127 labelWhenOpen : {
136128 opacity : 0 ,
137- top : this . getSpacing ( ) . desktopToolbarHeight / 2 ,
129+ top : spacing . desktopToolbarHeight / 2 ,
130+ } ,
131+ overlay : {
132+ height : '100%' ,
133+ width : '100%' ,
134+ position : 'fixed' ,
135+ top : 0 ,
136+ left : 0 ,
137+ zIndex : zIndex ,
138138 } ,
139139 } ;
140140
@@ -211,11 +211,13 @@ let DropDownMenu = React.createClass({
211211 autoWidth = { this . props . autoWidth }
212212 selectedIndex = { selectedIndex }
213213 menuItems = { menuItems }
214+ style = { styles . menu }
214215 menuItemStyle = { this . mergeAndPrefix ( styles . menuItem , this . props . menuItemStyle ) }
215216 hideable = { true }
216217 visible = { this . state . open }
217218 onRequestClose = { this . _onMenuRequestClose }
218219 onItemTap = { this . _onMenuItemClick } />
220+ { this . state . open && < div style = { styles . overlay } onTouchTap = { this . _handleOverlayTouchTap } /> }
219221 </ div >
220222 ) ;
221223 } ,
@@ -318,6 +320,12 @@ let DropDownMenu = React.createClass({
318320 this . setState ( { selectedIndex : Math . min ( this . state . selectedIndex + 1 , this . props . menuItems . length - 1 ) } ) ;
319321 } ,
320322
323+ _handleOverlayTouchTap ( ) {
324+ this . setState ( {
325+ open : false ,
326+ } ) ;
327+ } ,
328+
321329} ) ;
322330
323331module . exports = DropDownMenu ;
0 commit comments