Skip to content

Commit

Permalink
Merge 6c7c0fd into 8f89f99
Browse files Browse the repository at this point in the history
  • Loading branch information
yangxiuxiu1115 authored Jun 18, 2023
2 parents 8f89f99 + 6c7c0fd commit 20d82c5
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 2 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,12 @@ ReactDOM.render(
<td></td>
<td>additional css class of root dom node</td>
</tr>
<tr>
<td>popupStyle</td>
<td>CSSProperties</td>
<td></td>
<td>additional css style of root dom node</td>
</tr>
<tr>
<td>title</td>
<td>String/ReactElement</td>
Expand Down
3 changes: 3 additions & 0 deletions src/SubMenu/PopupTrigger.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export interface PopupTriggerProps {
visible: boolean;
children: React.ReactElement;
popup: React.ReactNode;
popupStyle?: React.CSSProperties;
popupClassName?: string;
popupOffset?: number[];
disabled: boolean;
Expand All @@ -32,6 +33,7 @@ export default function PopupTrigger({
visible,
children,
popup,
popupStyle,
popupClassName,
popupOffset,
disabled,
Expand Down Expand Up @@ -108,6 +110,7 @@ export default function PopupTrigger({
popupPlacement={popupPlacement}
popupVisible={innerVisible}
popup={popup}
popupStyle={popupStyle}
popupAlign={popupOffset && { offset: popupOffset }}
action={disabled ? [] : [triggerSubMenuAction]}
mouseEnterDelay={subMenuOpenDelay}
Expand Down
2 changes: 2 additions & 0 deletions src/SubMenu/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ const InternalSubMenu = (props: SubMenuProps) => {
// Popup
popupClassName,
popupOffset,
popupStyle,

// Events
onClick,
Expand Down Expand Up @@ -280,6 +281,7 @@ const InternalSubMenu = (props: SubMenuProps) => {
visible={!internalPopupClose && open && mode !== 'inline'}
popupClassName={popupClassName}
popupOffset={popupOffset}
popupStyle={popupStyle}
popup={
<MenuContextProvider
// Special handle of horizontal mode
Expand Down
1 change: 1 addition & 0 deletions src/interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export interface SubMenuType extends ItemSharedProps {
// >>>>> Popup
popupClassName?: string;
popupOffset?: number[];
popupStyle?: React.CSSProperties;

// >>>>> Events
onClick?: MenuClickEventHandler;
Expand Down
23 changes: 21 additions & 2 deletions tests/SubMenu.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import Menu, { MenuItem, SubMenu } from '../src';
import { isActive, last } from './util';

jest.mock('@rc-component/trigger', () => {
const react = require('react');
const react = require('react');
let Trigger = jest.requireActual('@rc-component/trigger/lib/mock');
Trigger = Trigger.default || Trigger;

Expand All @@ -17,7 +17,7 @@ jest.mock('@rc-component/trigger', () => {
});

jest.mock('../src/SubMenu/PopupTrigger', () => {
const react = require('react');
const react = require('react');
let PopupTrigger = jest.requireActual('../src/SubMenu/PopupTrigger');
PopupTrigger = PopupTrigger.default || PopupTrigger;

Expand Down Expand Up @@ -480,5 +480,24 @@ describe('SubMenu', () => {

expect(container.children).toMatchSnapshot();
});

it('submenu should support popupStyle', () => {
const { container } = render(
<Menu>
<SubMenu
key="s1"
title="submenu1"
popupStyle={{ zIndex: 100, width: 150 }}
>
<MenuItem key="s1-1">1</MenuItem>
</SubMenu>
</Menu>,
);

fireEvent.mouseEnter(container.querySelector('.rc-menu-submenu-title'));
runAllTimer();
expect((container.querySelector('.rc-menu-submenu-popup') as HTMLElement).style.zIndex).toEqual('100');
expect((container.querySelector('.rc-menu-submenu-popup') as HTMLElement).style.width).toEqual('150px');
});
});
/* eslint-enable */

0 comments on commit 20d82c5

Please sign in to comment.