File tree 1 file changed +9
-6
lines changed
1 file changed +9
-6
lines changed Original file line number Diff line number Diff line change 5
5
getBEMElement ,
6
6
getBEMModifier ,
7
7
} from 'mo/common/className' ;
8
+ import { mergeFunctions } from 'mo/common/utils' ;
8
9
9
10
export interface IActionBarItem < T = any > {
10
11
id : string ;
@@ -34,10 +35,8 @@ const labelClassName = getBEMElement(defaultActionBarClassName, 'label');
34
35
35
36
export function ActionBarItem ( props : IActionBarItem ) {
36
37
const { id, title, name, onClick } = props ;
37
- const click = ( e : React . MouseEvent ) => {
38
- if ( onClick ) {
39
- onClick ( e , props ) ;
40
- }
38
+ const handClick = ( e : React . MouseEvent ) => {
39
+ onClick ?.( e , props ) ;
41
40
} ;
42
41
const disabled = props . disabled ? itemDisabledClassName : null ;
43
42
const claNames = classNames (
@@ -49,7 +48,7 @@ export function ActionBarItem(props: IActionBarItem) {
49
48
return (
50
49
< li
51
50
className = { classNames ( itemClassName , disabled ) }
52
- onClick = { click }
51
+ onClick = { handClick }
53
52
key = { `${ id } ` }
54
53
>
55
54
< a className = { claNames } title = { title } >
@@ -65,7 +64,11 @@ export default function ActionBar<T = any>(props: IActionBar<T>) {
65
64
const claNames = classNames ( defaultActionBarClassName , className ) ;
66
65
67
66
const items = data . map ( ( item : IActionBarItem < T > ) => (
68
- < ActionBarItem key = { item . id } onClick = { onClick } { ...item } />
67
+ < ActionBarItem
68
+ key = { item . id }
69
+ { ...item }
70
+ onClick = { mergeFunctions ( onClick , item . onClick ) }
71
+ />
69
72
) ) ;
70
73
71
74
return (
You can’t perform that action at this time.
0 commit comments