File tree Expand file tree Collapse file tree 6 files changed +38
-1
lines changed
Expand file tree Collapse file tree 6 files changed +38
-1
lines changed Original file line number Diff line number Diff line change @@ -186,6 +186,12 @@ ReactDOM.render(<Menu>
186186 <th>() => document.body</th>
187187 <td>Where to render the DOM node of popup menu when the mode is horizontal or vertical</td>
188188 </tr>
189+ <tr>
190+ <td>builtinPlacements</td>
191+ <td>Object of alignConfigs for <a href="https://github.com/yiminghe/dom-align">dom-align</a></td>
192+ <th>see <a href="./src/placements.jsx">placements.jsx</a></th>
193+ <td>Describes how the popup menus should be positioned</td>
194+ </tr>
189195 </tbody>
190196</table >
191197
Original file line number Diff line number Diff line change @@ -31,6 +31,7 @@ class Menu extends React.Component {
3131 style : PropTypes . object ,
3232 activeKey : PropTypes . string ,
3333 prefixCls : PropTypes . string ,
34+ builtinPlacements : PropTypes . object ,
3435 } ;
3536
3637 static defaultProps = {
@@ -48,6 +49,7 @@ class Menu extends React.Component {
4849 className : '' ,
4950 mode : 'vertical' ,
5051 style : { } ,
52+ builtinPlacements : { } ,
5153 } ;
5254
5355 constructor ( props ) {
Original file line number Diff line number Diff line change @@ -359,6 +359,7 @@ export class SubMenu extends React.Component {
359359 subMenuCloseDelay : props . subMenuCloseDelay ,
360360 forceSubMenuRender : props . forceSubMenuRender ,
361361 triggerSubMenuAction : props . triggerSubMenuAction ,
362+ builtinPlacements : props . builtinPlacements ,
362363 defaultActiveFirst : props . store . getState ( )
363364 . defaultActiveFirst [ getMenuIdFromSubMenuEventKey ( props . eventKey ) ] ,
364365 multiple : props . multiple ,
@@ -489,6 +490,7 @@ export class SubMenu extends React.Component {
489490 subMenuOpenDelay,
490491 forceSubMenuRender,
491492 subMenuCloseDelay,
493+ builtinPlacements,
492494 } = props ;
493495 menuAllProps . forEach ( key => delete props [ key ] ) ;
494496 // Set onClick to null, to ignore propagated onClick event
@@ -508,7 +510,7 @@ export class SubMenu extends React.Component {
508510 prefixCls = { prefixCls }
509511 popupClassName = { `${ prefixCls } -popup ${ popupClassName } ` }
510512 getPopupContainer = { getPopupContainer }
511- builtinPlacements = { placements }
513+ builtinPlacements = { Object . assign ( { } , placements , builtinPlacements ) }
512514 popupPlacement = { popupPlacement }
513515 popupVisible = { isOpen }
514516 popupAlign = { popupAlign }
Original file line number Diff line number Diff line change @@ -285,6 +285,7 @@ export class SubPopupMenu extends React.Component {
285285 onOpenChange : this . onOpenChange ,
286286 onDeselect : this . onDeselect ,
287287 onSelect : this . onSelect ,
288+ builtinPlacements : props . builtinPlacements ,
288289 ...extraProps ,
289290 } ;
290291 if ( props . mode === 'inline' ) {
Original file line number Diff line number Diff line change @@ -95,6 +95,7 @@ export const menuAllProps = [
9595 'isSelected' ,
9696 'store' ,
9797 'activeKey' ,
98+ 'builtinPlacements' ,
9899
99100 // the following keys found need to be removed from test regression
100101 'attribute' ,
Original file line number Diff line number Diff line change @@ -263,4 +263,29 @@ describe('Menu', () => {
263263 wrapper . find ( 'li' ) . first ( ) . hasClass ( 'rc-menu-item-active' )
264264 ) . toBe ( true ) ;
265265 } ) ;
266+
267+ it ( 'should accept builtinPlacements' , ( ) => {
268+ const builtinPlacements = {
269+ leftTop : {
270+ points : [ 'tr' , 'tl' ] ,
271+ overflow : {
272+ adjustX : 0 ,
273+ adjustY : 0 ,
274+ } ,
275+ offset : [ 0 , 0 ] ,
276+ } ,
277+ } ;
278+
279+ const wrapper = mount (
280+ < Menu builtinPlacements = { builtinPlacements } >
281+ < MenuItem > menuItem</ MenuItem >
282+ < SubMenu title = "submenu" >
283+ < MenuItem > menuItem</ MenuItem >
284+ </ SubMenu >
285+ </ Menu >
286+ ) ;
287+
288+ expect ( wrapper . find ( 'Trigger' ) . prop ( 'builtinPlacements' ) . leftTop )
289+ . toEqual ( builtinPlacements . leftTop ) ;
290+ } ) ;
266291} ) ;
You can’t perform that action at this time.
0 commit comments