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
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,12 @@ ReactDOM.render(<Menu>
<th></th>
<td>corresponding to activeKey</td>
</tr>
<tr>
<td>tabIndex</td>
<td>String</td>
<th></th>
<td>the tabindex to assign to allow the user to tab to this item</td>
</tr>
</tbody>
</table>

Expand Down Expand Up @@ -244,6 +250,12 @@ ReactDOM.render(<Menu>
<th>false</th>
<td>no effect for click or keydown for this item</td>
</tr>
<tr>
<td>tabIndex</td>
<td>String</td>
<th></th>
<td>the tabindex to assign to allow the user to tab to this item</td>
</tr>
</tbody>
</table>

Expand Down
2 changes: 2 additions & 0 deletions src/MenuItem.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const MenuItem = React.createClass({
selected: React.PropTypes.bool,
disabled: React.PropTypes.bool,
title: React.PropTypes.string,
tabIndex: React.PropTypes.string,
onSelect: React.PropTypes.func,
onClick: React.PropTypes.func,
onDeselect: React.PropTypes.func,
Expand Down Expand Up @@ -122,6 +123,7 @@ const MenuItem = React.createClass({
...props.attribute,
title: props.title,
className: classnames(classes),
tabIndex: props.tabIndex,
role: 'menuitem',
'aria-selected': props.selected,
'aria-disabled': props.disabled,
Expand Down
17 changes: 17 additions & 0 deletions src/SubMenu.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const SubMenu = React.createClass({
parentMenu: React.PropTypes.object,
title: React.PropTypes.node,
onClick: React.PropTypes.func,
onFocus: React.PropTypes.func,
onOpenChange: React.PropTypes.func,
rootPrefixCls: React.PropTypes.string,
eventKey: React.PropTypes.string,
Expand All @@ -21,6 +22,7 @@ const SubMenu = React.createClass({
onDeselect: React.PropTypes.func,
onDestroy: React.PropTypes.func,
onItemHover: React.PropTypes.func,
tabIndex: React.PropTypes.string
},

mixins: [require('./SubMenuStateMixin')],
Expand Down Expand Up @@ -163,6 +165,15 @@ const SubMenu = React.createClass({
onSubMenuClick(info) {
this.props.onClick(this.addKeyPath(info));
},

onFocus: function onFocus () {
if (!this.props.open) {
this.triggerOpenChange(true);
}
else {
this.triggerOpenChange(false);
}
},

onSelect(info) {
this.props.onSelect(info);
Expand Down Expand Up @@ -252,12 +263,16 @@ const SubMenu = React.createClass({
classes[prefixCls] = true;
classes[prefixCls + '-' + props.mode] = 1;
let clickEvents = {};
let focusEvents = {};
let mouseEvents = {};
let titleMouseEvents = {};
if (!props.disabled) {
clickEvents = {
onClick: this.onClick,
};
focusEvents = {
onFocus: this.onFocus,
};
mouseEvents = {
onMouseLeave: this.onMouseLeave,
onMouseEnter: this.onSubTreeMouseEnter,
Expand All @@ -275,9 +290,11 @@ const SubMenu = React.createClass({
<li className={classnames(classes)} {...mouseEvents}>
<div
style={style}
tabIndex={tabIndex}
className={prefixCls + '-title'}
{...titleMouseEvents}
{...clickEvents}
{...focusEvents}
aria-open={props.open}
aria-owns={this._menuId}
aria-haspopup="true"
Expand Down