@@ -30,6 +30,7 @@ function BaseDraggableTabList({
30
30
outerWrapStyles,
31
31
onReorder,
32
32
onAddView,
33
+ showTempTab = false ,
33
34
tabVariant = 'filled' ,
34
35
...props
35
36
} : BaseDraggableTabListProps ) {
@@ -71,7 +72,7 @@ function BaseDraggableTabList({
71
72
useEffect ( ( ) => {
72
73
setTabListState ( state ) ;
73
74
// eslint-disable-next-line react-hooks/exhaustive-deps
74
- } , [ state . selectedItem , state . selectedKey , props . children ] ) ;
75
+ } , [ state . disabledKeys , state . selectedItem , state . selectedKey , props . children ] ) ;
75
76
76
77
// Detect tabs that overflow from the wrapper and put them in an overflow menu
77
78
const tabItemsRef = useRef < Record < string | number , HTMLLIElement | null > > ( { } ) ;
@@ -118,14 +119,11 @@ function BaseDraggableTabList({
118
119
variant = { tabVariant }
119
120
/>
120
121
</ Reorder . Item >
121
- < TabDivider
122
- layout
123
- active = {
124
- state . selectedKey === 'temporary-tab' ||
125
- ( state . selectedKey !== item . key &&
126
- state . collection . getKeyAfter ( item . key ) !== state . selectedKey )
127
- }
128
- />
122
+ { ( state . selectedKey === 'temporary-tab' ||
123
+ ( state . selectedKey !== item . key &&
124
+ state . collection . getKeyAfter ( item . key ) !== state . selectedKey ) ) && (
125
+ < TabDivider layout />
126
+ ) }
129
127
</ Fragment >
130
128
) ) }
131
129
</ TabListWrap >
@@ -136,9 +134,9 @@ function BaseDraggableTabList({
136
134
{ t ( 'Add View' ) }
137
135
</ AddViewButton >
138
136
</ MotionWrapper >
139
- < TabDivider layout active />
137
+ < TabDivider layout />
140
138
< MotionWrapper layout >
141
- { tempTab && (
139
+ { showTempTab && tempTab && (
142
140
< Tab
143
141
key = { tempTab . key }
144
142
item = { tempTab }
@@ -175,7 +173,12 @@ export interface DraggableTabListProps
175
173
* To be used as a direct child of the <Tabs /> component. See example usage
176
174
* in tabs.stories.js
177
175
*/
178
- export function DraggableTabList ( { items, onAddView, ...props } : DraggableTabListProps ) {
176
+ export function DraggableTabList ( {
177
+ items,
178
+ onAddView,
179
+ showTempTab,
180
+ ...props
181
+ } : DraggableTabListProps ) {
179
182
const collection = useCollection ( { items, ...props } , collectionFactory ) ;
180
183
181
184
const parsedItems = useMemo (
@@ -196,6 +199,7 @@ export function DraggableTabList({items, onAddView, ...props}: DraggableTabListP
196
199
< BaseDraggableTabList
197
200
items = { parsedItems }
198
201
onAddView = { onAddView }
202
+ showTempTab = { showTempTab }
199
203
disabledKeys = { disabledKeys }
200
204
{ ...props }
201
205
>
@@ -206,18 +210,11 @@ export function DraggableTabList({items, onAddView, ...props}: DraggableTabListP
206
210
207
211
DraggableTabList . Item = Item ;
208
212
209
- const TabDivider = styled ( motion . div ) < { active : boolean } > `
210
- ${ p =>
211
- p . active &&
212
- `
213
- background-color: ${ p . theme . gray200 } ;
214
- height: 50%;
215
- width: 1px;
216
- border-radius: 6px;
217
- margin-right: ${ space ( 0.5 ) } ;
218
- ` }
219
- margin-top: 1px;
220
- margin-left: ${ space ( 0.5 ) } ;
213
+ const TabDivider = styled ( motion . div ) `
214
+ height: 50%;
215
+ width: 1px;
216
+ border-radius: 6px;
217
+ background-color: ${ p => p . theme . gray200 } ;
221
218
` ;
222
219
223
220
const TabListOuterWrap = styled ( 'div' ) < {
@@ -255,13 +252,14 @@ const TabListWrap = styled('ul')`
255
252
const AddViewButton = styled ( Button ) `
256
253
display: flex;
257
254
color: ${ p => p . theme . gray300 } ;
255
+ padding-right: ${ space ( 0.5 ) } ;
256
+ margin: 4px 2px 2px 2px;
258
257
font-weight: normal;
259
- padding: ${ space ( 0.5 ) } ;
260
- transform: translateY(1px);
261
258
` ;
262
259
263
260
const StyledIconAdd = styled ( IconAdd ) `
264
261
margin-right: 4px;
262
+ margin-left: 2px;
265
263
` ;
266
264
267
265
const MotionWrapper = styled ( motion . div ) `
0 commit comments