Skip to content

Commit 608f2a3

Browse files
committed
fix: pass id to panel
1 parent 1979fbf commit 608f2a3

File tree

3 files changed

+11
-5
lines changed

3 files changed

+11
-5
lines changed

src/DrawerPanel.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ export interface DrawerPanelEvents {
1717
export interface DrawerPanelProps extends DrawerPanelEvents {
1818
prefixCls: string;
1919
className?: string;
20+
id?: string;
2021
style?: React.CSSProperties;
2122
children?: React.ReactNode;
2223
containerRef?: React.Ref<HTMLDivElement>;
@@ -29,6 +30,7 @@ const DrawerPanel = (props: DrawerPanelProps) => {
2930
style,
3031
children,
3132
containerRef,
33+
id,
3234
onMouseEnter,
3335
onMouseOver,
3436
onMouseLeave,
@@ -51,6 +53,7 @@ const DrawerPanel = (props: DrawerPanelProps) => {
5153
return (
5254
<>
5355
<div
56+
id={id}
5457
className={classNames(`${prefixCls}-content`, className)}
5558
style={{
5659
...style,

src/DrawerPopup.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,7 @@ function DrawerPopup(props: DrawerPopupProps, ref: React.Ref<HTMLDivElement>) {
295295
{...pickAttrs(props, { data: true })}
296296
>
297297
<DrawerPanel
298+
id={id}
298299
containerRef={motionRef}
299300
prefixCls={prefixCls}
300301
className={className}
@@ -321,7 +322,6 @@ function DrawerPopup(props: DrawerPopupProps, ref: React.Ref<HTMLDivElement>) {
321322
return (
322323
<DrawerContext.Provider value={mergedContext}>
323324
<div
324-
id={id}
325325
className={classNames(
326326
prefixCls,
327327
`${prefixCls}-${placement}`,

tests/index.spec.tsx

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -385,11 +385,14 @@ describe('rc-drawer-menu', () => {
385385
expect(leave).toHaveBeenCalled();
386386
});
387387

388-
it('pass id props to Drawer', () => {
389-
const { unmount } = render(<Drawer prefixCls='customer-prefixCls' id="muxin" open/>);
388+
it('pass id & className props to Panel', () => {
389+
const { unmount } = render(<Drawer className='customer-className' id="customer-id" open/>);
390390
expect(
391-
document.querySelector('.customer-prefixCls')
392-
).toHaveAttribute('id', 'muxin');
391+
document.querySelector('.rc-drawer-content')
392+
).toHaveClass('customer-className');
393+
expect(
394+
document.querySelector('.rc-drawer-content')
395+
).toHaveAttribute('id', 'customer-id');
393396
unmount();
394397
});
395398
});

0 commit comments

Comments
 (0)