Skip to content

Commit ee03a8b

Browse files
committed
feat: SSR render default fully
1 parent 346e69a commit ee03a8b

File tree

6 files changed

+138
-1
lines changed

6 files changed

+138
-1
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
"classnames": "2.x",
4747
"mini-store": "^3.0.1",
4848
"rc-motion": "^2.4.3",
49-
"rc-overflow": "^1.2.0-alpha.10",
49+
"rc-overflow": "^1.2.0-alpha.12",
5050
"rc-trigger": "^5.1.2",
5151
"rc-util": "^5.12.0",
5252
"resize-observer-polyfill": "^1.5.0",

src/Menu.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -483,6 +483,7 @@ const Menu: React.FC<MenuProps> = props => {
483483
? Overflow.INVALIDATE
484484
: Overflow.RESPONSIVE
485485
}
486+
ssr="full"
486487
data-menu-list
487488
onVisibleChange={newLastIndex => {
488489
setLastVisibleIndex(newLastIndex);

tests/Keyboard.spec.tsx

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import React from 'react';
33
import { act } from 'react-dom/test-utils';
44
import { spyElementPrototypes } from 'rc-util/lib/test/domHook';
5+
import { render } from 'enzyme';
56
import { mount } from './util';
67
import type { ReactWrapper } from './util';
78
import KeyCode from 'rc-util/lib/KeyCode';
@@ -41,6 +42,18 @@ describe('Menu.Keyboard', () => {
4142
});
4243
}
4344

45+
it('no data-menu-id by init', () => {
46+
const wrapper = render(
47+
<Menu mode="inline" openKeys={['light']}>
48+
<Menu.SubMenu key="light" title="Light">
49+
<Menu.Item key="bamboo">Bamboo</Menu.Item>
50+
</Menu.SubMenu>
51+
</Menu>,
52+
);
53+
54+
expect(wrapper).toMatchSnapshot();
55+
});
56+
4457
it('keydown works when children change', async () => {
4558
class App extends React.Component {
4659
state = {

tests/Responsive.spec.tsx

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import React from 'react';
33
import { act } from 'react-dom/test-utils';
44
import KeyCode from 'rc-util/lib/KeyCode';
5+
import { render } from 'enzyme';
56
import ResizeObserver from 'rc-resize-observer';
67
import { mount } from './util';
78
import Menu, { MenuItem, SubMenu } from '../src';
@@ -16,6 +17,18 @@ describe('Menu.Responsive', () => {
1617
jest.useRealTimers();
1718
});
1819

20+
it('ssr render full', () => {
21+
const wrapper = render(
22+
<Menu mode="horizontal">
23+
<MenuItem key="light">Light</MenuItem>
24+
<SubMenu key="bamboo">Bamboo</SubMenu>
25+
<MenuItem key="little">Little</MenuItem>
26+
</Menu>,
27+
);
28+
29+
expect(wrapper).toMatchSnapshot();
30+
});
31+
1932
it('show rest', () => {
2033
const onOpenChange = jest.fn();
2134
const wrapper = mount(
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
// Jest Snapshot v1, https://goo.gl/fbAQLP
2+
3+
exports[`Menu.Keyboard no data-menu-id by init 1`] = `
4+
<ul
5+
class="rc-menu rc-menu-root rc-menu-inline"
6+
data-menu-list="true"
7+
role="menu"
8+
tabindex="0"
9+
>
10+
<li
11+
class="rc-menu-submenu rc-menu-submenu-inline rc-menu-submenu-open"
12+
role="none"
13+
>
14+
<div
15+
aria-expanded="true"
16+
aria-haspopup="true"
17+
class="rc-menu-submenu-title"
18+
role="menuitem"
19+
style="padding-left:24px"
20+
tabindex="-1"
21+
title="Light"
22+
>
23+
Light
24+
<i
25+
class="rc-menu-submenu-arrow"
26+
/>
27+
</div>
28+
<ul
29+
class="rc-menu rc-menu-sub rc-menu-inline"
30+
data-menu-list="true"
31+
>
32+
<li
33+
class="rc-menu-item"
34+
role="menuitem"
35+
style="padding-left:24px"
36+
tabindex="-1"
37+
>
38+
Bamboo
39+
</li>
40+
</ul>
41+
</li>
42+
</ul>
43+
`;
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
// Jest Snapshot v1, https://goo.gl/fbAQLP
2+
3+
exports[`Menu.Responsive ssr render full 1`] = `
4+
Array [
5+
<ul
6+
class="rc-menu-overflow rc-menu rc-menu-root rc-menu-horizontal"
7+
data-menu-list="true"
8+
role="menu"
9+
tabindex="0"
10+
>
11+
<li
12+
class="rc-menu-overflow-item rc-menu-item"
13+
role="menuitem"
14+
style="opacity:1;order:0"
15+
tabindex="-1"
16+
>
17+
Light
18+
</li>
19+
<li
20+
class="rc-menu-overflow-item rc-menu-submenu rc-menu-submenu-horizontal"
21+
role="none"
22+
style="opacity:1;order:1"
23+
>
24+
<div
25+
aria-expanded="false"
26+
aria-haspopup="true"
27+
class="rc-menu-submenu-title"
28+
role="menuitem"
29+
tabindex="-1"
30+
>
31+
<i
32+
class="rc-menu-submenu-arrow"
33+
/>
34+
</div>
35+
</li>
36+
<li
37+
class="rc-menu-overflow-item rc-menu-item"
38+
role="menuitem"
39+
style="opacity:1;order:2"
40+
tabindex="-1"
41+
>
42+
Little
43+
</li>
44+
<li
45+
aria-hidden="true"
46+
class="rc-menu-overflow-item rc-menu-overflow-item-rest rc-menu-submenu rc-menu-submenu-horizontal"
47+
role="none"
48+
style="opacity:0;height:0;overflow-y:hidden;order:9007199254740991;pointer-events:none"
49+
>
50+
<div
51+
aria-expanded="false"
52+
aria-haspopup="true"
53+
class="rc-menu-submenu-title"
54+
role="menuitem"
55+
tabindex="-1"
56+
title="..."
57+
>
58+
...
59+
<i
60+
class="rc-menu-submenu-arrow"
61+
/>
62+
</div>
63+
</li>
64+
</ul>,
65+
"Bamboo",
66+
]
67+
`;

0 commit comments

Comments
 (0)