@@ -62,7 +86,7 @@ const DrawerPanel: React.FC
= (props) => {
{extra && {extra}
}
);
- }, [closable, closeIconNode, extra, headerStyle, prefixCls, title]);
+ }, [mergedClosable, closeIconNode, extra, headerStyle, prefixCls, title]);
const footerNode = React.useMemo
(() => {
if (!footer) {
diff --git a/components/drawer/__tests__/Drawer.test.tsx b/components/drawer/__tests__/Drawer.test.tsx
index 686e37c42b..f7fd04abd5 100644
--- a/components/drawer/__tests__/Drawer.test.tsx
+++ b/components/drawer/__tests__/Drawer.test.tsx
@@ -242,5 +242,72 @@ describe('Drawer', () => {
errorSpy.mockRestore();
});
+
+ it('should hide close button when closeIcon is null or false', async () => {
+ const { baseElement, rerender } = render(
+
+ Here is content of Drawer
+ ,
+ );
+ expect(baseElement.querySelector('.ant-drawer-close')).toBeNull();
+
+ rerender(
+
+ Here is content of Drawer
+ ,
+ );
+ expect(baseElement.querySelector('.ant-drawer-close')).toBeNull();
+
+ rerender(
+ Close}>
+ Here is content of Drawer
+ ,
+ );
+ expect(baseElement.querySelector('.custom-close')).not.toBeNull();
+
+ rerender(
+ Close}>
+ Here is content of Drawer
+ ,
+ );
+ expect(baseElement.querySelector('.custom-close2')).toBeNull();
+
+ rerender(
+ Close}>
+ Here is content of Drawer
+ ,
+ );
+ expect(baseElement.querySelector('.custom-close3')).not.toBeNull();
+
+ rerender(
+
+ Here is content of Drawer
+ ,
+ );
+ expect(baseElement.querySelector('.custom-drawer1 .ant-drawer-close')).not.toBeNull();
+ expect(baseElement.querySelector('.custom-drawer1 .anticon-close')).toBeNull();
+
+ rerender(
+
+ Here is content of Drawer
+ ,
+ );
+ expect(baseElement.querySelector('.custom-drawer2 .ant-drawer-close')).not.toBeNull();
+ expect(baseElement.querySelector('.custom-drawer2 .anticon-close')).toBeNull();
+
+ rerender(
+
+ Here is content of Drawer
+ ,
+ );
+ expect(baseElement.querySelector('.custom-drawer3 .anticon-close')).not.toBeNull();
+
+ rerender(
+
+ Here is content of Drawer
+ ,
+ );
+ expect(baseElement.querySelector('.anticon-close')).not.toBeNull();
+ });
});
});
diff --git a/components/drawer/index.en-US.md b/components/drawer/index.en-US.md
index e54cca9d93..608c3d7614 100644
--- a/components/drawer/index.en-US.md
+++ b/components/drawer/index.en-US.md
@@ -46,8 +46,7 @@ A Drawer is a panel that is typically overlaid on top of a page and slides in fr
| afterOpenChange | Callback after the animation ends when switching drawers | function(open) | - | |
| bodyStyle | Style of the drawer content part | CSSProperties | - | |
| className | Config Drawer Panel className. Use `rootClassName` if want to config top dom style | string | - | |
-| closable | Whether a close (x) button is visible on top left of the Drawer dialog or not | boolean | true | |
-| closeIcon | Custom close icon | ReactNode | <CloseOutlined /> | |
+| closeIcon | Custom close icon. 5.7.0: close button will be hidden when setting to `null` or `false` | boolean \| ReactNode | <CloseOutlined /> | |
| contentWrapperStyle | Style of the drawer wrapper of content part | CSSProperties | - | |
| destroyOnClose | Whether to unmount child components on closing drawer or not | boolean | false | |
| extra | Extra actions area at corner | ReactNode | - | 4.17.0 |
diff --git a/components/drawer/index.zh-CN.md b/components/drawer/index.zh-CN.md
index 6f6f9ec7cc..83b74a6016 100644
--- a/components/drawer/index.zh-CN.md
+++ b/components/drawer/index.zh-CN.md
@@ -45,8 +45,7 @@ demo:
| afterOpenChange | 切换抽屉时动画结束后的回调 | function(open) | - | |
| bodyStyle | 可用于设置 Drawer 内容部分的样式 | CSSProperties | - | |
| className | Drawer 容器外层 className 设置,如果需要设置最外层,请使用 rootClassName | string | - | |
-| closable | 是否显示左上角的关闭按钮 | boolean | true | |
-| closeIcon | 自定义关闭图标 | ReactNode | <CloseOutlined /> | |
+| closeIcon | 自定义关闭图标。5.7.0:设置为 `null` 或 `false` 时隐藏关闭按钮 | boolean \| ReactNode | <CloseOutlined /> | |
| contentWrapperStyle | 可用于设置 Drawer 包裹内容部分的样式 | CSSProperties | - | |
| destroyOnClose | 关闭时销毁 Drawer 里的子元素 | boolean | false | |
| extra | 抽屉右上角的操作区域 | ReactNode | - | 4.17.0 |