Skip to content

Commit 3ec3caf

Browse files
authored
feat: support data-* (#404)
* feat: support data-* Used https://github.com/react-component/dialog/pull/259as reference. * Add test
1 parent d1d81b7 commit 3ec3caf

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

src/DrawerPopup.tsx

+2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import DrawerPanel from './DrawerPanel';
66
import DrawerContext from './context';
77
import type { DrawerContextProps } from './context';
88
import KeyCode from 'rc-util/lib/KeyCode';
9+
import pickAttrs from 'rc-util/lib/pickAttrs';
910
import { parseWidthHeight } from './util';
1011

1112
const sentinelStyle: React.CSSProperties = {
@@ -273,6 +274,7 @@ function DrawerPopup(props: DrawerPopupProps, ref: React.Ref<HTMLDivElement>) {
273274
...motionStyle,
274275
...contentWrapperStyle,
275276
}}
277+
{...pickAttrs(props, { data: true })}
276278
>
277279
<DrawerPanel
278280
containerRef={motionRef}

tests/index.spec.tsx

+7
Original file line numberDiff line numberDiff line change
@@ -359,4 +359,11 @@ describe('rc-drawer-menu', () => {
359359
);
360360
errSpy.mockRestore();
361361
});
362+
363+
it('pass data props to internal div', () => {
364+
const value = 'bamboo';
365+
const { unmount } = render(<Drawer open data-attr={value} />);
366+
expect(document.querySelector('.rc-drawer-content-wrapper')).toHaveAttribute('data-attr',value);
367+
unmount();
368+
});
362369
});

0 commit comments

Comments
 (0)