Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,12 @@ ReactDOM.render(<Menu>
<th>() => document.body</th>
<td>Where to render the DOM node of popup menu when the mode is horizontal or vertical</td>
</tr>
<tr>
<td>builtinPlacements</td>
<td>Object of alignConfigs for <a href="https://github.com/yiminghe/dom-align">dom-align</a></td>
<th>see <a href="./src/placements.jsx">placements.jsx</a></th>
<td>Describes how the popup menus should be positioned</td>
</tr>
</tbody>
</table>

Expand Down
11 changes: 11 additions & 0 deletions src/Menu.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,14 @@ const Menu = createReactClass({
level: PropTypes.number,
selectable: PropTypes.bool,
multiple: PropTypes.bool,
builtinPlacements: PropTypes.object,
children: PropTypes.any,
},

childContextTypes: {
builtinPlacements: PropTypes.object,
},

mixins: [MenuMixin],

isRootMenu: true,
Expand Down Expand Up @@ -65,6 +70,12 @@ const Menu = createReactClass({
};
},

getChildContext() {
return {
builtinPlacements: this.props.builtinPlacements,
};
},

componentWillReceiveProps(nextProps) {
const props = {};
if ('selectedKeys' in nextProps) {
Expand Down
6 changes: 5 additions & 1 deletion src/SubMenu.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ const SubMenu = createReactClass({
onTitleClick: PropTypes.func,
},

contextTypes: {
builtinPlacements: PropTypes.object,
},

isRootMenu: false,

getDefaultProps() {
Expand Down Expand Up @@ -420,7 +424,7 @@ const SubMenu = createReactClass({
prefixCls={prefixCls}
popupClassName={`${prefixCls}-popup ${popupClassName}`}
getPopupContainer={getPopupContainer}
builtinPlacements={placements}
builtinPlacements={Object.assign({}, placements, this.context.builtinPlacements)}
popupPlacement={popupPlacement}
popupVisible={isOpen}
popup={children}
Expand Down