Skip to content

Commit

Permalink
fix #152
Browse files Browse the repository at this point in the history
  • Loading branch information
jaywcjlove committed Apr 29, 2021
1 parent a810938 commit 79bf33e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
9 changes: 8 additions & 1 deletion src/commands/group.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export type GroupOptions = Omit<ICommand<string>, 'children'> & {
};

export const group = (arr: ICommandChildCommands['children'], options?: GroupOptions): ICommand<string> => {
return {
let data = {
children: arr as any,
icon: (
<svg width="12" height="12" viewBox="0 0 520 520">
Expand All @@ -20,4 +20,11 @@ export const group = (arr: ICommandChildCommands['children'], options?: GroupOpt
...options,
keyCommand: 'group',
};
if (Array.isArray(data.children)) {
data.children = data.children.map(({ ...item }: ICommand) => {
item.parent = data;
return { ...item };
});
}
return data;
};
1 change: 1 addition & 0 deletions src/commands/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export type ICommandChildCommands<T = string> = {
};

export type ICommand<T = string> = {
parent?: ICommand;
keyCommand?: string;
name?: string;
shortcuts?: string;
Expand Down
2 changes: 1 addition & 1 deletion src/components/Toolbar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export default function Toolbar(props: IToolbarProps = {}) {
state.barPopup![item.groupName!] = false;
}
});
} else if (name) {
} else if (name || command.parent) {
Object.keys(state.barPopup || {}).forEach((keyName) => {
state.barPopup![keyName] = false;
});
Expand Down

1 comment on commit 79bf33e

@vercel
Copy link

@vercel vercel bot commented on 79bf33e Apr 29, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.