diff --git a/src/util.ts b/src/util.ts index 3bc37b94..86269a87 100644 --- a/src/util.ts +++ b/src/util.ts @@ -37,8 +37,10 @@ export function getRemovable( !editable || // Tabs cannot be removed when disabled disabled || - // If closable is not explicitly set to true, the remove button should be hidden when closeIcon is null or false - (closable !== true && (closeIcon === false || closeIcon === null)) + // closable is false + closable === false || + // If closable is undefined, the remove button should be hidden when closeIcon is null or false + (closable === undefined && (closeIcon === false || closeIcon === null)) ) { return false; } diff --git a/tests/index.test.tsx b/tests/index.test.tsx index 796f8941..c3ba7e3e 100644 --- a/tests/index.test.tsx +++ b/tests/index.test.tsx @@ -482,6 +482,11 @@ describe('Tabs.Basic', () => { closable: true, children: 'Light', }, + { + key: 'light5', + closable: false, + children: 'Light', + }, ] as any, }), ); @@ -492,6 +497,7 @@ describe('Tabs.Basic', () => { expect(container.querySelector('[data-node-key="light2"]').querySelector('.rc-tabs-tab-remove')).toBeFalsy(); expect(container.querySelector('[data-node-key="light3"]').querySelector('.rc-tabs-tab-remove')).toBeTruthy(); expect(container.querySelector('[data-node-key="light4"]').querySelector('.rc-tabs-tab-remove')).toBeTruthy(); + expect(container.querySelector('[data-node-key="light5"]').querySelector('.rc-tabs-tab-remove')).toBeFalsy(); }); });