Skip to content

Commit 2e7e5ad

Browse files
junyizJunyi
and
Junyi
authored
feat(layout): Add drawerProps for SettingDrawer (#8953)
* feat(layout): Add drawerExtra makes settingDrawer support extra * fix: drawerExtra -> drawerProps * test: Add test case for SettingDrawer --------- Co-authored-by: Junyi <[email protected]>
1 parent a197112 commit 2e7e5ad

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

packages/layout/src/components/SettingDrawer/index.tsx

+4
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import {
1717
Button,
1818
Divider,
1919
Drawer,
20+
DrawerProps,
2021
List,
2122
Switch,
2223
message,
@@ -79,6 +80,7 @@ export type SettingDrawerProps = {
7980
pathname?: string;
8081
disableUrlParams?: boolean;
8182
themeOnly?: boolean;
83+
drawerProps?: DrawerProps;
8284
};
8385

8486
export type SettingDrawerState = {
@@ -219,6 +221,7 @@ export const SettingDrawer: React.FC<SettingDrawerProps> = (props) => {
219221
pathname = window.location.pathname,
220222
disableUrlParams = true,
221223
themeOnly,
224+
drawerProps,
222225
} = props;
223226
const firstRender = useRef<boolean>(true);
224227

@@ -386,6 +389,7 @@ export const SettingDrawer: React.FC<SettingDrawerProps> = (props) => {
386389
style={{
387390
zIndex: 999,
388391
}}
392+
{...drawerProps}
389393
>
390394
<div className={`${baseClassName}-drawer-content ${hashId}`.trim()}>
391395
<Body

tests/layout/settingDrawer.test.tsx

+29
Original file line numberDiff line numberDiff line change
@@ -496,4 +496,33 @@ describe('settingDrawer.test', () => {
496496

497497
window.localStorage.setItem('umi_locale', 'zh-CN');
498498
});
499+
500+
it('🌺 drawerProps = undefined', async () => {
501+
const html = render(
502+
<SettingDrawer
503+
disableUrlParams
504+
collapse
505+
getContainer={false}
506+
drawerProps={undefined as any}
507+
/>,
508+
);
509+
510+
expect(html.asFragment()).toMatchSnapshot();
511+
});
512+
513+
it('🌺 drawerProps has extra', async () => {
514+
const { container } = render(
515+
<SettingDrawer
516+
disableUrlParams
517+
collapse
518+
getContainer={false}
519+
drawerProps={{
520+
closable: true,
521+
extra: 'extra'
522+
}}
523+
/>,
524+
);
525+
526+
expect(container.querySelectorAll('div.ant-drawer-extra')[0].innerHTML).toEqual('extra');
527+
});
499528
});

0 commit comments

Comments
 (0)