@@ -6,6 +6,7 @@ import * as React from 'react';
6
6
import { useEffect , useState } from 'react' ;
7
7
import type { EditableConfig , Tab , TabsLocale } from '../interface' ;
8
8
import AddButton from './AddButton' ;
9
+ import { getRemovable } from '../util' ;
9
10
10
11
export interface OperationNodeProps {
11
12
prefixCls : string ;
@@ -83,17 +84,18 @@ function OperationNode(
83
84
aria-label = { dropdownAriaLabel !== undefined ? dropdownAriaLabel : 'expanded dropdown' }
84
85
>
85
86
{ tabs . map ( tab => {
86
- const removable = editable && tab . closable !== false && ! tab . disabled ;
87
+ const { closable, disabled, closeIcon, key, label } = tab ;
88
+ const removable = getRemovable ( closable , closeIcon , editable , disabled ) ;
87
89
return (
88
90
< MenuItem
89
- key = { tab . key }
90
- id = { `${ popupId } -${ tab . key } ` }
91
+ key = { key }
92
+ id = { `${ popupId } -${ key } ` }
91
93
role = "option"
92
- aria-controls = { id && `${ id } -panel-${ tab . key } ` }
93
- disabled = { tab . disabled }
94
+ aria-controls = { id && `${ id } -panel-${ key } ` }
95
+ disabled = { disabled }
94
96
>
95
97
{ /* {tab.tab} */ }
96
- < span > { tab . label } </ span >
98
+ < span > { label } </ span >
97
99
{ removable && (
98
100
< button
99
101
type = "button"
@@ -102,10 +104,10 @@ function OperationNode(
102
104
className = { `${ dropdownPrefix } -menu-item-remove` }
103
105
onClick = { e => {
104
106
e . stopPropagation ( ) ;
105
- onRemoveTab ( e , tab . key ) ;
107
+ onRemoveTab ( e , key ) ;
106
108
} }
107
109
>
108
- { tab . closeIcon || editable . removeIcon || '×' }
110
+ { closeIcon || editable . removeIcon || '×' }
109
111
</ button >
110
112
) }
111
113
</ MenuItem >
0 commit comments