From 255d5b4d2add4db9595a9817a1e63579d34b1176 Mon Sep 17 00:00:00 2001 From: smeng9 Date: Mon, 10 Nov 2025 22:49:23 +0800 Subject: [PATCH 1/6] migrate deprecated `` --- examples/crm/src/companies/CompanyShow.tsx | 56 +++++++------- .../crm/src/contacts/ContactListContent.tsx | 46 +++++------ examples/demo/src/dashboard/PendingOrder.tsx | 27 +++---- examples/demo/src/reviews/ReviewItem.tsx | 2 +- examples/simple/src/tags/TagList.tsx | 11 ++- .../src/list/SimpleList/SimpleList.tsx | 77 ++++++++++--------- .../src/list/SimpleList/SimpleListItem.tsx | 11 ++- .../src/list/SimpleList/SimpleListLoading.tsx | 13 ++-- .../src/list/filter/FilterListItem.tsx | 31 ++++---- .../list/filter/SavedQueryFilterListItem.tsx | 21 ++--- 10 files changed, 157 insertions(+), 138 deletions(-) diff --git a/examples/crm/src/companies/CompanyShow.tsx b/examples/crm/src/companies/CompanyShow.tsx index 00a486eeaa5..feb8131a66c 100644 --- a/examples/crm/src/companies/CompanyShow.tsx +++ b/examples/crm/src/companies/CompanyShow.tsx @@ -8,7 +8,6 @@ import { ListItem, ListItemAvatar, ListItemButton, - ListItemSecondaryAction, ListItemText, Stack, Typography, @@ -143,7 +142,22 @@ const ContactsIterator = () => { {contacts.map(contact => ( - + + last activity{' '} + {formatDistance(contact.last_seen, now)} ago{' '} + + + ), + })} + > { } /> - {contact.last_seen && ( - - - last activity{' '} - {formatDistance(contact.last_seen, now)}{' '} - ago - - - )} @@ -216,7 +217,20 @@ const DealsIterator = () => { {deals.map(deal => ( - + + last activity{' '} + {formatDistance(deal.updated_at, now)} ago{' '} + + } + > { } /> - - - last activity{' '} - {formatDistance(deal.updated_at, now)} ago{' '} - - ))} diff --git a/examples/crm/src/contacts/ContactListContent.tsx b/examples/crm/src/contacts/ContactListContent.tsx index 6fe345abe99..88ce8ea7ea1 100644 --- a/examples/crm/src/contacts/ContactListContent.tsx +++ b/examples/crm/src/contacts/ContactListContent.tsx @@ -6,7 +6,6 @@ import { ListItemButton, ListItemAvatar, ListItemIcon, - ListItemSecondaryAction, ListItemText, Typography, useMediaQuery, @@ -50,7 +49,29 @@ export const ContactListContent = () => { {contacts.map(contact => ( - + + {!isSmall && 'last activity '} + {formatRelative( + contact.last_seen, + now + )}{' '} + + + ), + })} + > { } /> - {contact.last_seen && ( - - - {!isSmall && 'last activity '} - {formatRelative( - contact.last_seen, - now - )}{' '} - - - - )} diff --git a/examples/demo/src/dashboard/PendingOrder.tsx b/examples/demo/src/dashboard/PendingOrder.tsx index 49a7ced13c6..577911f1157 100644 --- a/examples/demo/src/dashboard/PendingOrder.tsx +++ b/examples/demo/src/dashboard/PendingOrder.tsx @@ -1,7 +1,6 @@ import * as React from 'react'; import { ListItem, - ListItemSecondaryAction, ListItemAvatar, ListItemText, Avatar, @@ -26,7 +25,20 @@ export const PendingOrder = (props: Props) => { }); return ( - + + {order.total}$ + + } + > {isPending ? ( @@ -49,17 +61,6 @@ export const PendingOrder = (props: Props) => { : '', })} /> - - - {order.total}$ - - ); diff --git a/examples/demo/src/reviews/ReviewItem.tsx b/examples/demo/src/reviews/ReviewItem.tsx index 0447fce935f..3def4cfe5ff 100644 --- a/examples/demo/src/reviews/ReviewItem.tsx +++ b/examples/demo/src/reviews/ReviewItem.tsx @@ -72,7 +72,7 @@ export const ReviewItem = () => { } secondary={record.comment} - secondaryTypographyProps={{ noWrap: true }} + slotProps={{ secondary: { noWrap: true } }} /> diff --git a/examples/simple/src/tags/TagList.tsx b/examples/simple/src/tags/TagList.tsx index bf3dd443ee5..5e538d5ddac 100644 --- a/examples/simple/src/tags/TagList.tsx +++ b/examples/simple/src/tags/TagList.tsx @@ -12,7 +12,6 @@ import { List, ListItem, ListItemText, - ListItemSecondaryAction, Collapse, Card, Stack, @@ -76,16 +75,16 @@ const SubTree = ({ level, root, getChildNodes, openChildren, toggleNode }) => { const open = openChildren.includes(root.id); return ( - + } + > hasChildren && toggleNode(root)}> {hasChildren && open && } {hasChildren && !open && } {!hasChildren &&
 
} - - - -
diff --git a/packages/ra-ui-materialui/src/list/SimpleList/SimpleList.tsx b/packages/ra-ui-materialui/src/list/SimpleList/SimpleList.tsx index b4bd8238b92..da150cef818 100644 --- a/packages/ra-ui-materialui/src/list/SimpleList/SimpleList.tsx +++ b/packages/ra-ui-materialui/src/list/SimpleList/SimpleList.tsx @@ -125,13 +125,33 @@ export const SimpleList = ( rowSx={rowSx} rowStyle={rowStyle} resource={resource} + {...((rightAvatar || rightIcon) && { + secondaryAction: ( + <> + {rightAvatar && ( + + {renderAvatar( + record, + rightAvatar + )} + + )} + {rightIcon && ( + + {rightIcon( + record, + record.id + )} + + )} + + ), + })} > const SimpleListItemContent = ( props: SimpleListItemProps ) => { - const { - leftAvatar, - leftIcon, - primaryText, - rightAvatar, - rightIcon, - secondaryText, - tertiaryText, - } = props; + const { leftAvatar, leftIcon, primaryText, secondaryText, tertiaryText } = + props; const resource = useResourceContext(props); const record = useRecordContext(props); const getRecordRepresentation = useGetRecordRepresentation(resource); const translate = useTranslate(); - const renderAvatar = ( - record: RecordType, - avatarCallback: FunctionToElement - ) => { - const avatarValue = avatarCallback(record, record.id); - if ( - typeof avatarValue === 'string' && - (avatarValue.startsWith('http') || avatarValue.startsWith('data:')) - ) { - return ; - } else { - return {avatarValue}; - } - }; - if (!record) return null; return ( @@ -250,22 +248,25 @@ const SimpleListItemContent = ( secondaryText(record, record.id)) } /> - {(rightAvatar || rightIcon) && ( - - {rightAvatar && ( - {renderAvatar(record, rightAvatar)} - )} - {rightIcon && ( - - {rightIcon(record, record.id)} - - )} - - )} ); }; +const renderAvatar = ( + record: RecordType, + avatarCallback: FunctionToElement +) => { + const avatarValue = avatarCallback(record, record.id); + if ( + typeof avatarValue === 'string' && + (avatarValue.startsWith('http') || avatarValue.startsWith('data:')) + ) { + return ; + } else { + return {avatarValue}; + } +}; + const PREFIX = 'RaSimpleList'; export const SimpleListClasses = { diff --git a/packages/ra-ui-materialui/src/list/SimpleList/SimpleListItem.tsx b/packages/ra-ui-materialui/src/list/SimpleList/SimpleListItem.tsx index 33339852c1b..9322ba38091 100644 --- a/packages/ra-ui-materialui/src/list/SimpleList/SimpleListItem.tsx +++ b/packages/ra-ui-materialui/src/list/SimpleList/SimpleListItem.tsx @@ -17,7 +17,15 @@ import { RowClickFunction } from '../types'; export const SimpleListItem = ( props: SimpleListItemProps ) => { - const { children, linkType, rowClick, rowIndex, rowSx, rowStyle } = props; + const { + children, + linkType, + rowClick, + rowIndex, + rowSx, + rowStyle, + secondaryAction, + } = props; const resource = useResourceContext(props); const record = useRecordContext(props); const navigate = useNavigate(); @@ -64,6 +72,7 @@ export const SimpleListItem = ( width: '100%', }, }} + secondaryAction={secondaryAction} > { return oneSecondHasPassed ? ( {times(nbFakeLines, key => ( - +  , + })} + > {hasLeftAvatarOrIcon && (   @@ -64,11 +68,6 @@ export const SimpleListLoading = (inProps: SimpleListLoadingProps) => { hasSecondaryText ? : undefined } /> - {hasRightAvatarOrIcon && ( - -   - - )}
))} diff --git a/packages/ra-ui-materialui/src/list/filter/FilterListItem.tsx b/packages/ra-ui-materialui/src/list/filter/FilterListItem.tsx index fc2505b437b..db58df482ff 100644 --- a/packages/ra-ui-materialui/src/list/filter/FilterListItem.tsx +++ b/packages/ra-ui-materialui/src/list/filter/FilterListItem.tsx @@ -13,7 +13,6 @@ import { ListItemIcon, type ListItemProps, ListItemText, - ListItemSecondaryAction, } from '@mui/material'; import CancelIcon from '@mui/icons-material/CancelOutlined'; import { @@ -174,7 +173,23 @@ export const FilterListItem = memo((inProps: FilterListItemProps) => { const handleClick = () => setFilters(toggleFilter(value, filterValues)); return ( - + { + event.stopPropagation(); + handleClick(); + }} + > + + + ), + })} + {...rest} + > { className={FilterListItemClasses.listItemText} data-selected={isSelected ? 'true' : 'false'} /> - {isSelected && ( - { - event.stopPropagation(); - handleClick(); - }} - > - - - - - )} ); diff --git a/packages/ra-ui-materialui/src/list/filter/SavedQueryFilterListItem.tsx b/packages/ra-ui-materialui/src/list/filter/SavedQueryFilterListItem.tsx index eb5a11da1fb..e68b480a948 100644 --- a/packages/ra-ui-materialui/src/list/filter/SavedQueryFilterListItem.tsx +++ b/packages/ra-ui-materialui/src/list/filter/SavedQueryFilterListItem.tsx @@ -6,7 +6,6 @@ import { ListItemButton, type ListItemProps, ListItemText, - ListItemSecondaryAction, styled, type ComponentsOverrides, useThemeProps, @@ -69,7 +68,18 @@ export const SavedQueryFilterListItem = memo( isSelected ? removeFilter() : addFilter(); return ( - + + + + ), + })} + > - {isSelected && ( - - - - - - )} ); From 50747af21ea627fdbb09906f465ed3870728ca90 Mon Sep 17 00:00:00 2001 From: smeng9 <38666763+smeng9@users.noreply.github.com> Date: Tue, 11 Nov 2025 14:59:10 +0800 Subject: [PATCH 2/6] remove unused import --- packages/ra-ui-materialui/src/list/SimpleList/SimpleList.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/ra-ui-materialui/src/list/SimpleList/SimpleList.tsx b/packages/ra-ui-materialui/src/list/SimpleList/SimpleList.tsx index da150cef818..b7df4384d4d 100644 --- a/packages/ra-ui-materialui/src/list/SimpleList/SimpleList.tsx +++ b/packages/ra-ui-materialui/src/list/SimpleList/SimpleList.tsx @@ -3,7 +3,6 @@ import { List, ListItemAvatar, ListItemIcon, - ListItemSecondaryAction, ListItemText, ListProps, } from '@mui/material'; From 82e32a2fcee96f45a2b6a18495176e35e93871a8 Mon Sep 17 00:00:00 2001 From: smeng9 Date: Thu, 13 Nov 2025 10:20:29 +0800 Subject: [PATCH 3/6] fix code style and make it readable --- examples/crm/src/companies/CompanyShow.tsx | 8 ++++---- examples/crm/src/contacts/ContactListContent.tsx | 8 ++++---- .../ra-ui-materialui/src/list/SimpleList/SimpleList.tsx | 8 ++++---- .../src/list/SimpleList/SimpleListLoading.tsx | 6 +++--- .../ra-ui-materialui/src/list/filter/FilterListItem.tsx | 8 ++++---- .../src/list/filter/SavedQueryFilterListItem.tsx | 8 ++++---- 6 files changed, 23 insertions(+), 23 deletions(-) diff --git a/examples/crm/src/companies/CompanyShow.tsx b/examples/crm/src/companies/CompanyShow.tsx index feb8131a66c..0edb7f7edae 100644 --- a/examples/crm/src/companies/CompanyShow.tsx +++ b/examples/crm/src/companies/CompanyShow.tsx @@ -144,8 +144,8 @@ const ContactsIterator = () => { { {formatDistance(contact.last_seen, now)} ago{' '} - ), - })} + ) : null + } > { { )}{' '} - ), - })} + ) : null + } > ( rowSx={rowSx} rowStyle={rowStyle} resource={resource} - {...((rightAvatar || rightIcon) && { - secondaryAction: ( + secondaryAction={ + rightAvatar || rightIcon ? ( <> {rightAvatar && ( @@ -144,8 +144,8 @@ export const SimpleList = ( )} - ), - })} + ) : null + } > { {times(nbFakeLines, key => (  , - })} + secondaryAction={ + hasRightAvatarOrIcon ?   : null + } > {hasLeftAvatarOrIcon && ( diff --git a/packages/ra-ui-materialui/src/list/filter/FilterListItem.tsx b/packages/ra-ui-materialui/src/list/filter/FilterListItem.tsx index db58df482ff..b25b8e7dbd3 100644 --- a/packages/ra-ui-materialui/src/list/filter/FilterListItem.tsx +++ b/packages/ra-ui-materialui/src/list/filter/FilterListItem.tsx @@ -175,8 +175,8 @@ export const FilterListItem = memo((inProps: FilterListItemProps) => { return ( { @@ -186,8 +186,8 @@ export const FilterListItem = memo((inProps: FilterListItemProps) => { > - ), - })} + ) : null + } {...rest} > - ), - })} + ) : null + } > Date: Fri, 21 Nov 2025 13:02:50 +0800 Subject: [PATCH 4/6] fix display issue after deprecating list item secondary action --- examples/crm/src/companies/CompanyShow.tsx | 51 +++++------- .../crm/src/contacts/ContactListContent.tsx | 42 +++++----- examples/demo/src/dashboard/PendingOrder.tsx | 24 +++--- examples/simple/src/tags/TagList.tsx | 7 +- .../src/list/SimpleList/SimpleList.tsx | 78 +++++++++---------- .../src/list/SimpleList/SimpleListItem.tsx | 11 +-- 6 files changed, 95 insertions(+), 118 deletions(-) diff --git a/examples/crm/src/companies/CompanyShow.tsx b/examples/crm/src/companies/CompanyShow.tsx index 0edb7f7edae..f77bf7d76b0 100644 --- a/examples/crm/src/companies/CompanyShow.tsx +++ b/examples/crm/src/companies/CompanyShow.tsx @@ -142,22 +142,7 @@ const ContactsIterator = () => { {contacts.map(contact => ( - - last activity{' '} - {formatDistance(contact.last_seen, now)} ago{' '} - - - ) : null - } - > + { } /> + {contact.last_seen && ( + + last activity{' '} + {formatDistance(contact.last_seen, now)} ago{' '} + + + )} @@ -217,20 +213,7 @@ const DealsIterator = () => { {deals.map(deal => ( - - last activity{' '} - {formatDistance(deal.updated_at, now)} ago{' '} - - } - > + { } /> + + last activity{' '} + {formatDistance(deal.updated_at, now)} ago{' '} + ))} diff --git a/examples/crm/src/contacts/ContactListContent.tsx b/examples/crm/src/contacts/ContactListContent.tsx index 2a6ccf9ee9c..7033a88f11a 100644 --- a/examples/crm/src/contacts/ContactListContent.tsx +++ b/examples/crm/src/contacts/ContactListContent.tsx @@ -49,29 +49,7 @@ export const ContactListContent = () => { {contacts.map(contact => ( - - {!isSmall && 'last activity '} - {formatRelative( - contact.last_seen, - now - )}{' '} - - - ) : null - } - > + { } /> + {contact.last_seen && ( + + {!isSmall && 'last activity '} + {formatRelative( + contact.last_seen, + now + )}{' '} + + + )} diff --git a/examples/demo/src/dashboard/PendingOrder.tsx b/examples/demo/src/dashboard/PendingOrder.tsx index 577911f1157..12f60904490 100644 --- a/examples/demo/src/dashboard/PendingOrder.tsx +++ b/examples/demo/src/dashboard/PendingOrder.tsx @@ -25,20 +25,7 @@ export const PendingOrder = (props: Props) => { }); return ( - - {order.total}$ - - } - > + {isPending ? ( @@ -61,6 +48,15 @@ export const PendingOrder = (props: Props) => { : '', })} /> + + {order.total}$ + ); diff --git a/examples/simple/src/tags/TagList.tsx b/examples/simple/src/tags/TagList.tsx index 5e538d5ddac..6df604b622a 100644 --- a/examples/simple/src/tags/TagList.tsx +++ b/examples/simple/src/tags/TagList.tsx @@ -12,6 +12,7 @@ import { List, ListItem, ListItemText, + ListItemSecondaryAction, Collapse, Card, Stack, @@ -62,7 +63,7 @@ const Tree = () => { getChildNodes={getChildNodes} openChildren={openChildren} toggleNode={toggleNode} - level={1} + level={0} /> ))} @@ -77,7 +78,9 @@ const SubTree = ({ level, root, getChildNodes, openChildren, toggleNode }) => { ({ + paddingLeft: theme.spacing(level * 2), + })} secondaryAction={} > hasChildren && toggleNode(root)}> diff --git a/packages/ra-ui-materialui/src/list/SimpleList/SimpleList.tsx b/packages/ra-ui-materialui/src/list/SimpleList/SimpleList.tsx index 921788deafe..b6e3d5820a9 100644 --- a/packages/ra-ui-materialui/src/list/SimpleList/SimpleList.tsx +++ b/packages/ra-ui-materialui/src/list/SimpleList/SimpleList.tsx @@ -1,5 +1,6 @@ import { Avatar, + Box, List, ListItemAvatar, ListItemIcon, @@ -124,33 +125,13 @@ export const SimpleList = ( rowSx={rowSx} rowStyle={rowStyle} resource={resource} - secondaryAction={ - rightAvatar || rightIcon ? ( - <> - {rightAvatar && ( - - {renderAvatar( - record, - rightAvatar - )} - - )} - {rightIcon && ( - - {rightIcon( - record, - record.id - )} - - )} - - ) : null - } > const SimpleListItemContent = ( props: SimpleListItemProps ) => { - const { leftAvatar, leftIcon, primaryText, secondaryText, tertiaryText } = - props; + const { + leftAvatar, + leftIcon, + primaryText, + rightAvatar, + rightIcon, + secondaryText, + tertiaryText, + } = props; const resource = useResourceContext(props); const record = useRecordContext(props); const getRecordRepresentation = useGetRecordRepresentation(resource); const translate = useTranslate(); + const renderAvatar = ( + record: RecordType, + avatarCallback: FunctionToElement + ) => { + const avatarValue = avatarCallback(record, record.id); + if ( + typeof avatarValue === 'string' && + (avatarValue.startsWith('http') || avatarValue.startsWith('data:')) + ) { + return ; + } else { + return {avatarValue}; + } + }; + if (!record) return null; return ( @@ -247,25 +250,22 @@ const SimpleListItemContent = ( secondaryText(record, record.id)) } /> + {(rightAvatar || rightIcon) && ( + + {rightAvatar && ( + {renderAvatar(record, rightAvatar)} + )} + {rightIcon && ( + + {rightIcon(record, record.id)} + + )} + + )} ); }; -const renderAvatar = ( - record: RecordType, - avatarCallback: FunctionToElement -) => { - const avatarValue = avatarCallback(record, record.id); - if ( - typeof avatarValue === 'string' && - (avatarValue.startsWith('http') || avatarValue.startsWith('data:')) - ) { - return ; - } else { - return {avatarValue}; - } -}; - const PREFIX = 'RaSimpleList'; export const SimpleListClasses = { diff --git a/packages/ra-ui-materialui/src/list/SimpleList/SimpleListItem.tsx b/packages/ra-ui-materialui/src/list/SimpleList/SimpleListItem.tsx index 9322ba38091..33339852c1b 100644 --- a/packages/ra-ui-materialui/src/list/SimpleList/SimpleListItem.tsx +++ b/packages/ra-ui-materialui/src/list/SimpleList/SimpleListItem.tsx @@ -17,15 +17,7 @@ import { RowClickFunction } from '../types'; export const SimpleListItem = ( props: SimpleListItemProps ) => { - const { - children, - linkType, - rowClick, - rowIndex, - rowSx, - rowStyle, - secondaryAction, - } = props; + const { children, linkType, rowClick, rowIndex, rowSx, rowStyle } = props; const resource = useResourceContext(props); const record = useRecordContext(props); const navigate = useNavigate(); @@ -72,7 +64,6 @@ export const SimpleListItem = ( width: '100%', }, }} - secondaryAction={secondaryAction} > Date: Fri, 21 Nov 2025 13:23:53 +0800 Subject: [PATCH 5/6] remove unused import --- examples/simple/src/tags/TagList.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/examples/simple/src/tags/TagList.tsx b/examples/simple/src/tags/TagList.tsx index 6df604b622a..c9a8cb25806 100644 --- a/examples/simple/src/tags/TagList.tsx +++ b/examples/simple/src/tags/TagList.tsx @@ -12,7 +12,6 @@ import { List, ListItem, ListItemText, - ListItemSecondaryAction, Collapse, Card, Stack, From fdbc39c83c1c704a7ffbcb59784856fc9ac48e1a Mon Sep 17 00:00:00 2001 From: smeng9 Date: Sun, 23 Nov 2025 20:46:21 +0800 Subject: [PATCH 6/6] fix listItemSecondaryAction styles by moving disableGutter prop to parent --- packages/ra-ui-materialui/src/list/filter/FilterListItem.tsx | 2 +- .../src/list/filter/SavedQueryFilterListItem.tsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/ra-ui-materialui/src/list/filter/FilterListItem.tsx b/packages/ra-ui-materialui/src/list/filter/FilterListItem.tsx index b25b8e7dbd3..f000a0827b6 100644 --- a/packages/ra-ui-materialui/src/list/filter/FilterListItem.tsx +++ b/packages/ra-ui-materialui/src/list/filter/FilterListItem.tsx @@ -175,6 +175,7 @@ export const FilterListItem = memo((inProps: FilterListItemProps) => { return ( { {...rest} > @@ -83,7 +84,6 @@ export const SavedQueryFilterListItem = memo(