Skip to content

Commit

Permalink
feat: support popupClassName (#539)
Browse files Browse the repository at this point in the history
  • Loading branch information
MadCcc authored Jun 2, 2022
1 parent 7534586 commit 1e505e4
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/TabNavList/OperationNode.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export interface OperationNodeProps {
removeAriaLabel?: string;
onTabClick: (key: React.Key, e: React.MouseEvent | React.KeyboardEvent) => void;
tabMoving?: boolean;
popupClassName?: string;
}

function OperationNode(
Expand All @@ -42,6 +43,7 @@ function OperationNode(
rtl,
removeAriaLabel,
onTabClick,
popupClassName,
}: OperationNodeProps,
ref: React.Ref<HTMLDivElement>,
) {
Expand Down Expand Up @@ -191,7 +193,7 @@ function OperationNode(
visible={open}
transitionName={moreTransitionName}
onVisibleChange={setOpen}
overlayClassName={overlayClassName}
overlayClassName={classNames(overlayClassName, popupClassName)}
mouseEnterDelay={0.1}
mouseLeaveDelay={0.1}
>
Expand Down
1 change: 1 addition & 0 deletions src/TabNavList/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ export interface TabNavListProps {
onTabClick: (activeKey: string, e: React.MouseEvent | React.KeyboardEvent) => void;
onTabScroll?: OnTabScroll;
children?: (node: React.ReactElement) => React.ReactElement;
popupClassName?: string;
}

interface ExtraContentProps {
Expand Down
4 changes: 4 additions & 0 deletions src/Tabs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ export interface TabsProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'o
moreIcon?: React.ReactNode;
/** @private Internal usage. Not promise will rename in future */
moreTransitionName?: string;

popupClassName?: string;
}

function parseTabList(children: React.ReactNode): Tab[] {
Expand Down Expand Up @@ -110,6 +112,7 @@ function Tabs(
onChange,
onTabClick,
onTabScroll,
popupClassName,
...restProps
}: TabsProps,
ref: React.Ref<HTMLDivElement>,
Expand Down Expand Up @@ -214,6 +217,7 @@ function Tabs(
extra: tabBarExtraContent,
style: tabBarStyle,
panes: children,
popupClassName,
};

if (renderTabBar) {
Expand Down
20 changes: 20 additions & 0 deletions tests/overflow.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -374,4 +374,24 @@ describe('Tabs.Overflow', () => {
});
expect(wrapper.find('.rc-tabs-dropdown-menu').first().text()).not.toContain('miu');
});

it('should support popupClassName', () => {
jest.useFakeTimers();
const wrapper = mount(getTabs({ popupClassName: 'custom-popup' }));

triggerResize(wrapper);
act(() => {
jest.runAllTimers();
wrapper.update();
});

wrapper.find('.rc-tabs-nav-more').simulate('mouseenter');
act(() => {
jest.runAllTimers();
wrapper.update();
});
expect(wrapper.find('.rc-tabs-dropdown').first().getDOMNode().className).toContain(
'custom-popup',
);
});
});

1 comment on commit 1e505e4

@vercel
Copy link

@vercel vercel bot commented on 1e505e4 Jun 2, 2022

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.