Skip to content

Commit

Permalink
feat(menu-item): onClick事件增加value返回值 (#2441)
Browse files Browse the repository at this point in the history
* feat(menu-item): onClick事件增加value返回值

fix #2621

* docs(menu): menu-item 组件文档修改
  • Loading branch information
dexterBo authored Aug 15, 2023
1 parent 2169e18 commit 79a5976
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/menu/MenuItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const MenuItem: FC<MenuItemProps> = (props) => {
e.stopPropagation();
if (disabled) return;

onClick && onClick({ e });
onClick && onClick({ e, value });
if (value !== active) onChange(value);
setState({ active: value });
};
Expand Down
2 changes: 1 addition & 1 deletion src/menu/menu.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ href | String | - | 跳转链接 | N
icon | TElement | - | 图标。TS 类型:`TNode`[通用类型定义](https://github.com/Tencent/tdesign-react/blob/develop/src/common.ts) | N
target | String | - | 链接或路由跳转方式。可选项:_blank/_self/_parent/_top | N
value | String / Number | - | 菜单项唯一标识。TS 类型:`MenuValue` | N
onClick | Function | | TS 类型:`(context: { e: MouseEvent }) => void`<br/>点击时触发 | N
onClick | Function | | TS 类型:`(context: { e: MouseEvent, value: MenuValue }) => void`<br/>点击时触发 | N

### MenuGroup Props

Expand Down
2 changes: 1 addition & 1 deletion src/menu/type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ export interface TdMenuItemProps {
/**
* 点击时触发
*/
onClick?: (context: { e: MouseEvent<HTMLElement> }) => void;
onClick?: (context: { e: MouseEvent<HTMLElement>; value: MenuValue }) => void;
}

export interface TdMenuGroupProps {
Expand Down

0 comments on commit 79a5976

Please sign in to comment.