Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 17 additions & 22 deletions examples/crm/src/companies/CompanyShow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import {
ListItem,
ListItemAvatar,
ListItemButton,
ListItemSecondaryAction,
ListItemText,
Stack,
Typography,
Expand Down Expand Up @@ -170,17 +169,15 @@ const ContactsIterator = () => {
}
/>
{contact.last_seen && (
<ListItemSecondaryAction>
<Typography
variant="body2"
color="textSecondary"
component="span"
>
last activity{' '}
{formatDistance(contact.last_seen, now)}{' '}
ago <Status status={contact.status} />
</Typography>
</ListItemSecondaryAction>
<Typography
variant="body2"
color="textSecondary"
component="span"
>
last activity{' '}
{formatDistance(contact.last_seen, now)} ago{' '}
<Status status={contact.status} />
</Typography>
)}
</ListItemButton>
</ListItem>
Expand Down Expand Up @@ -239,16 +236,14 @@ const DealsIterator = () => {
</>
}
/>
<ListItemSecondaryAction>
<Typography
variant="body2"
color="textSecondary"
component="span"
>
last activity{' '}
{formatDistance(deal.updated_at, now)} ago{' '}
</Typography>
</ListItemSecondaryAction>
<Typography
variant="body2"
color="textSecondary"
component="span"
>
last activity{' '}
{formatDistance(deal.updated_at, now)} ago{' '}
</Typography>
</ListItemButton>
</ListItem>
))}
Expand Down
26 changes: 11 additions & 15 deletions examples/crm/src/contacts/ContactListContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import {
ListItemButton,
ListItemAvatar,
ListItemIcon,
ListItemSecondaryAction,
ListItemText,
Typography,
useMediaQuery,
Expand Down Expand Up @@ -102,25 +101,22 @@ export const ContactListContent = () => {
}
/>
{contact.last_seen && (
<ListItemSecondaryAction
<Typography
variant="body2"
color="textSecondary"
title={contact.last_seen}
sx={{
top: '10px',
transform: 'none',
}}
>
<Typography
variant="body2"
color="textSecondary"
title={contact.last_seen}
>
{!isSmall && 'last activity '}
{formatRelative(
contact.last_seen,
now
)}{' '}
<Status status={contact.status} />
</Typography>
</ListItemSecondaryAction>
{!isSmall && 'last activity '}
{formatRelative(
contact.last_seen,
now
)}{' '}
<Status status={contact.status} />
</Typography>
)}
</ListItemButton>
</ListItem>
Expand Down
21 changes: 9 additions & 12 deletions examples/demo/src/dashboard/PendingOrder.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import * as React from 'react';
import {
ListItem,
ListItemSecondaryAction,
ListItemAvatar,
ListItemText,
Avatar,
Expand Down Expand Up @@ -49,17 +48,15 @@ export const PendingOrder = (props: Props) => {
: '',
})}
/>
<ListItemSecondaryAction>
<Box
component="span"
sx={{
marginRight: '1em',
color: 'text.primary',
}}
>
{order.total}$
</Box>
</ListItemSecondaryAction>
<Box
component="span"
sx={{
marginRight: '1em',
color: 'text.primary',
}}
>
{order.total}$
</Box>
</ListItemButton>
</ListItem>
);
Expand Down
2 changes: 1 addition & 1 deletion examples/demo/src/reviews/ReviewItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export const ReviewItem = () => {
</Fragment>
}
secondary={record.comment}
secondaryTypographyProps={{ noWrap: true }}
slotProps={{ secondary: { noWrap: true } }}
/>
</ListItemButton>
</ListItem>
Expand Down
15 changes: 8 additions & 7 deletions examples/simple/src/tags/TagList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import {
List,
ListItem,
ListItemText,
ListItemSecondaryAction,
Collapse,
Card,
Stack,
Expand Down Expand Up @@ -63,7 +62,7 @@ const Tree = () => {
getChildNodes={getChildNodes}
openChildren={openChildren}
toggleNode={toggleNode}
level={1}
level={0}
/>
))}
</List>
Expand All @@ -76,16 +75,18 @@ const SubTree = ({ level, root, getChildNodes, openChildren, toggleNode }) => {
const open = openChildren.includes(root.id);
return (
<Fragment>
<ListItem disablePadding style={{ paddingLeft: level * 16 }}>
<ListItem
disablePadding
sx={theme => ({
paddingLeft: theme.spacing(level * 2),
})}
secondaryAction={<EditButton record={root} />}
>
<ListItemButton onClick={() => hasChildren && toggleNode(root)}>
{hasChildren && open && <ExpandLess />}
{hasChildren && !open && <ExpandMore />}
{!hasChildren && <div style={{ width: 24 }}>&nbsp;</div>}
<ListItemText primary={root.name.en} />

<ListItemSecondaryAction>
<EditButton record={root} />
</ListItemSecondaryAction>
</ListItemButton>
</ListItem>
<Collapse in={open} timeout="auto" unmountOnExit>
Expand Down
6 changes: 3 additions & 3 deletions packages/ra-ui-materialui/src/list/SimpleList/SimpleList.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import {
Avatar,
Box,
List,
ListItemAvatar,
ListItemIcon,
ListItemSecondaryAction,
ListItemText,
ListProps,
} from '@mui/material';
Expand Down Expand Up @@ -251,7 +251,7 @@ const SimpleListItemContent = <RecordType extends RaRecord = any>(
}
/>
{(rightAvatar || rightIcon) && (
<ListItemSecondaryAction>
<Box>
{rightAvatar && (
<Avatar>{renderAvatar(record, rightAvatar)}</Avatar>
)}
Expand All @@ -260,7 +260,7 @@ const SimpleListItemContent = <RecordType extends RaRecord = any>(
{rightIcon(record, record.id)}
</ListItemIcon>
)}
</ListItemSecondaryAction>
</Box>
)}
</>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import {
type ListProps,
ListItem,
ListItemAvatar,
ListItemSecondaryAction,
ListItemText,
} from '@mui/material';
import { useTimeout } from 'ra-core';
Expand All @@ -37,7 +36,12 @@ export const SimpleListLoading = (inProps: SimpleListLoadingProps) => {
return oneSecondHasPassed ? (
<StyledList className={className} {...rest}>
{times(nbFakeLines, key => (
<ListItem key={key}>
<ListItem
key={key}
secondaryAction={
hasRightAvatarOrIcon ? <Avatar>&nbsp;</Avatar> : null
}
>
{hasLeftAvatarOrIcon && (
<ListItemAvatar>
<Avatar>&nbsp;</Avatar>
Expand All @@ -64,11 +68,6 @@ export const SimpleListLoading = (inProps: SimpleListLoadingProps) => {
hasSecondaryText ? <Placeholder /> : undefined
}
/>
{hasRightAvatarOrIcon && (
<ListItemSecondaryAction>
<Avatar>&nbsp;</Avatar>
</ListItemSecondaryAction>
)}
</ListItem>
))}
</StyledList>
Expand Down
33 changes: 18 additions & 15 deletions packages/ra-ui-materialui/src/list/filter/FilterListItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import {
ListItemIcon,
type ListItemProps,
ListItemText,
ListItemSecondaryAction,
} from '@mui/material';
import CancelIcon from '@mui/icons-material/CancelOutlined';
import {
Expand Down Expand Up @@ -174,9 +173,25 @@ export const FilterListItem = memo((inProps: FilterListItemProps) => {
const handleClick = () => setFilters(toggleFilter(value, filterValues));

return (
<StyledListItem disablePadding {...rest}>
<StyledListItem
disablePadding
disableGutters
secondaryAction={
isSelected ? (
<IconButton
size="small"
onClick={event => {
event.stopPropagation();
handleClick();
}}
>
<CancelIcon />
</IconButton>
) : null
}
{...rest}
>
<ListItemButton
disableGutters
onClick={handleClick}
selected={isSelected}
className={FilterListItemClasses.listItemButton}
Expand All @@ -197,18 +212,6 @@ export const FilterListItem = memo((inProps: FilterListItemProps) => {
className={FilterListItemClasses.listItemText}
data-selected={isSelected ? 'true' : 'false'}
/>
{isSelected && (
<ListItemSecondaryAction
onClick={event => {
event.stopPropagation();
handleClick();
}}
>
<IconButton size="small">
<CancelIcon />
</IconButton>
</ListItemSecondaryAction>
)}
</ListItemButton>
</StyledListItem>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import {
ListItemButton,
type ListItemProps,
ListItemText,
ListItemSecondaryAction,
styled,
type ComponentsOverrides,
useThemeProps,
Expand Down Expand Up @@ -69,24 +68,28 @@ export const SavedQueryFilterListItem = memo(
isSelected ? removeFilter() : addFilter();

return (
<StyledListItem className={className} sx={sx} disablePadding>
<StyledListItem
className={className}
sx={sx}
disablePadding
disableGutters
secondaryAction={
isSelected ? (
<IconButton size="small" onClick={toggleFilter}>
<CancelIcon />
</IconButton>
) : null
}
>
<ListItemButton
onClick={toggleFilter}
selected={isSelected}
disableGutters
className={SavedQueryFilterListItemClasses.listItemButton}
>
<ListItemText
primary={label}
className={SavedQueryFilterListItemClasses.listItemText}
/>
{isSelected && (
<ListItemSecondaryAction>
<IconButton size="small" onClick={toggleFilter}>
<CancelIcon />
</IconButton>
</ListItemSecondaryAction>
)}
</ListItemButton>
</StyledListItem>
);
Expand Down
Loading