Skip to content

Commit

Permalink
feat: support data-* (#404)
Browse files Browse the repository at this point in the history
* feat: support data-*

Used https://github.com/react-component/dialog/pull/259as reference.

* Add test
  • Loading branch information
rkuykendall authored May 29, 2023
1 parent d1d81b7 commit 3ec3caf
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/DrawerPopup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import DrawerPanel from './DrawerPanel';
import DrawerContext from './context';
import type { DrawerContextProps } from './context';
import KeyCode from 'rc-util/lib/KeyCode';
import pickAttrs from 'rc-util/lib/pickAttrs';
import { parseWidthHeight } from './util';

const sentinelStyle: React.CSSProperties = {
Expand Down Expand Up @@ -273,6 +274,7 @@ function DrawerPopup(props: DrawerPopupProps, ref: React.Ref<HTMLDivElement>) {
...motionStyle,
...contentWrapperStyle,
}}
{...pickAttrs(props, { data: true })}
>
<DrawerPanel
containerRef={motionRef}
Expand Down
7 changes: 7 additions & 0 deletions tests/index.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -359,4 +359,11 @@ describe('rc-drawer-menu', () => {
);
errSpy.mockRestore();
});

it('pass data props to internal div', () => {
const value = 'bamboo';
const { unmount } = render(<Drawer open data-attr={value} />);
expect(document.querySelector('.rc-drawer-content-wrapper')).toHaveAttribute('data-attr',value);
unmount();
});
});

0 comments on commit 3ec3caf

Please sign in to comment.