Browse Source

📝 fix Drawer `forceRender` doc and tsd (#21774)

close #15287
pull/21784/head
偏右 5 years ago
committed by GitHub
parent
commit
9eaaea14a7
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 17
      components/drawer/__tests__/Drawer.test.js
  2. 1
      components/drawer/index.en-US.md
  3. 1
      components/drawer/index.tsx
  4. 1
      components/drawer/index.zh-CN.md

17
components/drawer/__tests__/Drawer.test.js

@ -1,5 +1,5 @@
import React from 'react';
import { render } from 'enzyme';
import { render, mount } from 'enzyme';
import Drawer from '..';
import mountTest from '../../../tests/shared/mountTest';
import rtlTest from '../../../tests/shared/rtlTest';
@ -89,4 +89,19 @@ describe('Drawer', () => {
);
expect(wrapper).toMatchSnapshot();
});
it('forceRender works', () => {
const wrapper = mount(
<Drawer>
<button type="button" className="forceRender">should not be rendered</button>
</Drawer>,
);
expect(wrapper.find('button.forceRender').length).toBe(0);
const wrapper2 = mount(
<Drawer forceRender>
<button type="button" className="forceRender">should be rendered</button>
</Drawer>,
);
expect(wrapper2.find('button.forceRender').length).toBe(1);
})
});

1
components/drawer/index.en-US.md

@ -21,6 +21,7 @@ A Drawer is a panel that is typically overlaid on top of a page and slides in fr
| --- | --- | --- | --- |
| closable | Whether a close (x) button is visible on top right of the Drawer dialog or not. | boolean | true |
| destroyOnClose | Whether to unmount child components on closing drawer or not. | boolean | false |
| forceRender | Prerender Drawer component forcely | boolean | false |
| getContainer | Return the mounted node for Drawer. | HTMLElement \| `() => HTMLElement` \| Selectors \| false | 'body' |
| mask | Whether to show mask or not. | Boolean | true |
| maskClosable | Clicking on the mask (area outside the Drawer) to close the Drawer or not. | boolean | true |

1
components/drawer/index.tsx

@ -21,6 +21,7 @@ type placementType = typeof PlacementTypes[number];
export interface DrawerProps {
closable?: boolean;
destroyOnClose?: boolean;
forceRender?: boolean;
getContainer?: string | HTMLElement | getContainerFunc | false;
maskClosable?: boolean;
mask?: boolean;

1
components/drawer/index.zh-CN.md

@ -20,6 +20,7 @@ title: Drawer
| --- | --- | --- | --- |
| closable | 是否显示右上角的关闭按钮 | boolean | true |
| destroyOnClose | 关闭时销毁 Drawer 里的子元素 | boolean | false |
| forceRender | 预渲染 Drawer 内元素 | boolean | false |
| getContainer | 指定 Drawer 挂载的 HTML 节点, false 为挂载在当前 dom | HTMLElement \| `() => HTMLElement` \| Selectors \| false | 'body' |
| maskClosable | 点击蒙层是否允许关闭 | boolean | true |
| mask | 是否展示遮罩 | boolean | true |

Loading…
Cancel
Save