Skip to content

Commit 63c3643

Browse files
authored
fix: Reduce the required props for ResizableBox (#264)
1 parent b6b2c53 commit 63c3643

2 files changed

Lines changed: 13 additions & 1 deletion

File tree

__tests__/ResizableBox.test.tsx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,18 @@ describe('render ResizableBox', () => {
263263
});
264264
});
265265

266+
test('renders with only width and height (all DefaultProps optional)', () => {
267+
const {container} = render(
268+
<ResizableBox width={200} height={100}>
269+
<span />
270+
</ResizableBox>
271+
);
272+
const divElement = container.querySelector('div');
273+
expect(divElement).toHaveStyle({ width: '200px', height: '100px' });
274+
// Default 'se' handle should be present
275+
expect(container.querySelector('.react-resizable-handle-se')).toBeInTheDocument();
276+
});
277+
266278
describe('DOM updates after resize', () => {
267279
test('DOM width and height update after resize', async () => {
268280
const boxRef = React.createRef();

lib/propTypes.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ export type ResizeHandleFn = (
4646
ref: React.RefObject<HTMLElement>,
4747
) => React.ReactElement<any>;
4848

49-
export type Props = DefaultProps & {
49+
export type Props = Partial<DefaultProps> & {
5050
children: React.ReactElement<any>;
5151
className?: string | null;
5252
draggableOpts?: Partial<React.ComponentProps<typeof DraggableCore>> | null;

0 commit comments

Comments
 (0)