Skip to content

Commit

Permalink
Merge pull request #6926 from marmelab/fix-bulkactions-type
Browse files Browse the repository at this point in the history
Fix List bulkActionButtons prop does not handle the value true
  • Loading branch information
djhi committed Dec 2, 2021
2 parents d5bfda4 + 3b64748 commit e063037
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
12 changes: 8 additions & 4 deletions packages/ra-ui-materialui/src/list/ListView.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from 'react';
import { Children, cloneElement, ReactElement } from 'react';
import { Children, cloneElement, isValidElement, ReactElement } from 'react';
import PropTypes from 'prop-types';
import Card from '@material-ui/core/Card';
import classnames from 'classnames';
Expand Down Expand Up @@ -68,11 +68,15 @@ export const ListView = (props: ListViewProps) => {
})}
key={version}
>
{bulkActionButtons !== false && bulkActionButtons && (
{bulkActionButtons !== false ? (
<BulkActionsToolbar {...controllerProps}>
{bulkActionButtons}
{isValidElement(bulkActionButtons) ? (
bulkActionButtons
) : (
<DefaultBulkActionButtons />
)}
</BulkActionsToolbar>
)}
) : null}
{children &&
// @ts-ignore-line
cloneElement(Children.only(children), {
Expand Down
2 changes: 1 addition & 1 deletion packages/ra-ui-materialui/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
export interface ListProps extends ResourceComponentProps {
actions?: ReactElement | false;
aside?: ReactElement;
bulkActionButtons?: ReactElement | false;
bulkActionButtons?: ReactElement | boolean;
classes?: any;
className?: string;
component?: ElementType;
Expand Down

0 comments on commit e063037

Please sign in to comment.