Skip to content

Commit

Permalink
fix: TabPane should support closeIcon
Browse files Browse the repository at this point in the history
  • Loading branch information
zombieJ committed Jun 1, 2020
1 parent ca7d2ae commit 79f1606
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 2 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ React.render(
| key | string | - | corresponding to activeKey, should be unique |
| forceRender | boolean | false | forced render of content in tabs, not lazy render after clicking on tabs |
| tab | ReactNode | - | current tab's title corresponding to current tabPane |
| closeIcon | ReactNode | - | Config close icon |

## Development

Expand Down
4 changes: 2 additions & 2 deletions src/TabNavList/TabNode.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ function TabNode(
id,
active,
rtl,
tab: { key, tab, disabled },
tab: { key, tab, disabled, closeIcon },
tabBarGutter,
tabPosition,
closable,
Expand Down Expand Up @@ -99,7 +99,7 @@ function TabNode(
}
}}
>
{editable.removeIcon || '×'}
{closeIcon || editable.removeIcon || '×'}
</span>
)}
</button>
Expand Down
1 change: 1 addition & 0 deletions src/sugar/TabPane.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export interface TabPaneProps {
children?: React.ReactNode;
forceRender?: boolean;
closable?: boolean;
closeIcon?: React.ReactNode;
}

// eslint-disable-next-line @typescript-eslint/no-unused-vars
Expand Down
16 changes: 16 additions & 0 deletions tests/index.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,22 @@ describe('Tabs.Basic', () => {
});
});
});

it('customize closeIcon', () => {
const onEdit = jest.fn();
const wrapper = mount(
getTabs({
editable: { onEdit },
children: [
<TabPane tab="light" closeIcon={<span className="close-light" />}>
Light
</TabPane>,
],
}),
);

expect(wrapper.find('.rc-tabs-tab-remove').find('.close-light').length).toBeTruthy();
});
});

it('extra', () => {
Expand Down

1 comment on commit 79f1606

@vercel
Copy link

@vercel vercel bot commented on 79f1606 Jun 1, 2020

Choose a reason for hiding this comment

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

Please sign in to comment.