Skip to content

Commit

Permalink
EuiDroppable now accepts multiple children (TypeScript) (#2634)
Browse files Browse the repository at this point in the history
  • Loading branch information
seeruk authored and thompsongl committed Dec 12, 2019
1 parent 5969b28 commit 3516212
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ No public interface changes since `17.1.2`.

- Fixed `EuiCodeEditor` custom mode file error by initializing with existing mode ([#2616](https://github.com/elastic/eui/pull/2616))
- Removed `EuiIcon` default titles ([#2632](https://github.com/elastic/eui/pull/2632))
- Fixed `EuiDroppable` not accepting multiple children when using TypeScript ([#2634](https://github.com/elastic/eui/pull/2634))

## [`17.1.1`](https://github.com/elastic/eui/tree/v17.1.1)

Expand Down
15 changes: 15 additions & 0 deletions src/components/drag_and_drop/__snapshots__/droppable.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,21 @@ exports[`EuiDroppable can be given ReactElement children 1`] = `
</div>
`;

exports[`EuiDroppable can be given multiple ReactElement children 1`] = `
<div
class="euiDroppable euiDroppable--noGrow"
data-react-beautiful-dnd-droppable="3"
data-test-subj="droppable"
>
<div />
<div />
<div />
<div
class="euiDroppable__placeholder"
/>
</div>
`;

exports[`EuiDroppable is rendered 1`] = `
<div
class="euiDroppable euiDroppable--noGrow"
Expand Down
15 changes: 15 additions & 0 deletions src/components/drag_and_drop/droppable.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,21 @@ describe('EuiDroppable', () => {
expect(component).toMatchSnapshot();
});

test('can be given multiple ReactElement children', () => {
const handler = jest.fn();
const component = render(
<EuiDragDropContext onDragEnd={handler} {...requiredProps}>
<EuiDroppable droppableId="testDroppable">
<div />
<div />
<div />
</EuiDroppable>
</EuiDragDropContext>
);

expect(component).toMatchSnapshot();
});

describe('custom behavior', () => {
describe('cloneDraggables', () => {
const handler = jest.fn();
Expand Down
2 changes: 1 addition & 1 deletion src/components/drag_and_drop/droppable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export type EuiDroppableSpacing = keyof typeof spacingToClassNameMap;
export interface EuiDroppableProps
extends CommonProps,
Omit<DroppableProps, 'children'> {
children: ReactElement | DroppableProps['children'];
children: ReactElement | ReactElement[] | DroppableProps['children'];
className?: string;
/**
* Makes its items immutable. Dragging creates cloned items that can be dropped elsewhere.
Expand Down

0 comments on commit 3516212

Please sign in to comment.