Skip to content

Commit

Permalink
fix: close button should be hidden when closable is false (#666)
Browse files Browse the repository at this point in the history
* fix: close button should be hidden when closable is false

* fix: close button should be hidden when closable is false
  • Loading branch information
kiner-tang authored Jun 19, 2023
1 parent a1d2d78 commit be28662
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
6 changes: 6 additions & 0 deletions tests/index.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -482,6 +482,11 @@ describe('Tabs.Basic', () => {
closable: true,
children: 'Light',
},
{
key: 'light5',
closable: false,
children: 'Light',
},
] as any,
}),
);
Expand All @@ -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();

});
});
Expand Down

1 comment on commit be28662

@vercel
Copy link

@vercel vercel bot commented on be28662 Jun 19, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

tabs – ./

tabs-react-component.vercel.app
tabs-git-master-react-component.vercel.app

Please sign in to comment.