Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduced a remainOnSelect property #379

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 6 additions & 0 deletions README.md
Expand Up @@ -93,6 +93,12 @@ ReactDOM.render(
<th>false</th>
<td>whether allow multiple select</td>
</tr>
<tr>
<td>remainOnSelect</td>
<td>Boolean</td>
<th>false</th>
<td>whether to allow the menu to remain showing after an item is selected</td>
</tr>
<tr>
<td>selectable</td>
<td>Boolean</td>
Expand Down
1 change: 1 addition & 0 deletions docs/examples/multiple.tsx
Expand Up @@ -27,6 +27,7 @@ function Demo() {
onSelect={handleSelect}
onDeselect={handleDeselect}
defaultSelectedKeys={['2', '1-1']}
remainOnSelect
>
<SubMenu title={titleRight} key="1">
<MenuItem key="1-1">0-1</MenuItem>
Expand Down
5 changes: 4 additions & 1 deletion src/Menu.tsx
Expand Up @@ -61,6 +61,9 @@ export interface MenuProps

inlineCollapsed?: boolean;

/** allow the menu to remain active after an item is selected. */
remainOnSelect?: boolean;

/** SiderContextProps of layout in ant design */
siderCollapsed?: boolean;
collapsedWidth?: string | number;
Expand Down Expand Up @@ -242,7 +245,7 @@ class Menu extends React.Component<MenuProps, MenuState> {
props: { onOpenChange },
} = this;

if (mode !== 'inline' && !('openKeys' in this.props)) {
if (mode !== 'inline' && !('openKeys' in this.props) && !(this.props.remainOnSelect)) {
// closing vertical popup submenu after click it
store.setState({
openKeys: [],
Expand Down