Skip to content

Commit be28662

Browse files
authored
fix: close button should be hidden when closable is false (#666)
* fix: close button should be hidden when closable is false * fix: close button should be hidden when closable is false
1 parent a1d2d78 commit be28662

2 files changed

Lines changed: 10 additions & 2 deletions

File tree

src/util.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,10 @@ export function getRemovable(
3737
!editable ||
3838
// Tabs cannot be removed when disabled
3939
disabled ||
40-
// If closable is not explicitly set to true, the remove button should be hidden when closeIcon is null or false
41-
(closable !== true && (closeIcon === false || closeIcon === null))
40+
// closable is false
41+
closable === false ||
42+
// If closable is undefined, the remove button should be hidden when closeIcon is null or false
43+
(closable === undefined && (closeIcon === false || closeIcon === null))
4244
) {
4345
return false;
4446
}

tests/index.test.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -482,6 +482,11 @@ describe('Tabs.Basic', () => {
482482
closable: true,
483483
children: 'Light',
484484
},
485+
{
486+
key: 'light5',
487+
closable: false,
488+
children: 'Light',
489+
},
485490
] as any,
486491
}),
487492
);
@@ -492,6 +497,7 @@ describe('Tabs.Basic', () => {
492497
expect(container.querySelector('[data-node-key="light2"]').querySelector('.rc-tabs-tab-remove')).toBeFalsy();
493498
expect(container.querySelector('[data-node-key="light3"]').querySelector('.rc-tabs-tab-remove')).toBeTruthy();
494499
expect(container.querySelector('[data-node-key="light4"]').querySelector('.rc-tabs-tab-remove')).toBeTruthy();
500+
expect(container.querySelector('[data-node-key="light5"]').querySelector('.rc-tabs-tab-remove')).toBeFalsy();
495501

496502
});
497503
});

0 commit comments

Comments
 (0)