File tree Expand file tree Collapse file tree 4 files changed +21
-16
lines changed
ra-ui-materialui/src/list/datagrid Expand file tree Collapse file tree 4 files changed +21
-16
lines changed Original file line number Diff line number Diff line change @@ -139,7 +139,7 @@ const englishMessages: TranslationMessages = {
139139 skip_nav : 'Skip to content' ,
140140 } ,
141141 sort : {
142- sort_by : 'Sort by %{field } %{order}' ,
142+ sort_by : 'Sort by %{field_lower_first } %{order}' ,
143143 ASC : 'ascending' ,
144144 DESC : 'descending' ,
145145 } ,
Original file line number Diff line number Diff line change @@ -144,7 +144,7 @@ const frenchMessages: TranslationMessages = {
144144 skip_nav : 'Aller au contenu' ,
145145 } ,
146146 sort : {
147- sort_by : 'Trier par %{field } %{order}' ,
147+ sort_by : 'Trier par %{field_lower_first } %{order}' ,
148148 ASC : 'croissant' ,
149149 DESC : 'décroissant' ,
150150 } ,
Original file line number Diff line number Diff line change @@ -39,13 +39,13 @@ describe('<DatagridHeaderCell />', () => {
3939 it ( 'should use the default inferred field label in its tooltip when using a React element as the field label' , async ( ) => {
4040 render ( < LabelElements /> ) ;
4141 await screen . findByText ( 'ID' ) ;
42- await screen . findByLabelText ( 'Sort by Id descending' ) ;
42+ await screen . findByLabelText ( 'Sort by id descending' ) ;
4343 await screen . findByText ( 'TITLE' ) ;
44- await screen . findByLabelText ( 'Sort by Title ascending' ) ;
44+ await screen . findByLabelText ( 'Sort by title ascending' ) ;
4545 await screen . findByText ( 'AUTHOR' ) ;
46- await screen . findByLabelText ( 'Sort by Author ascending' ) ;
46+ await screen . findByLabelText ( 'Sort by author ascending' ) ;
4747 await screen . findByText ( 'YEAR' ) ;
48- await screen . findByLabelText ( 'Sort by Year ascending' ) ;
48+ await screen . findByLabelText ( 'Sort by year ascending' ) ;
4949 } ) ;
5050
5151 describe ( 'sorting on a column' , ( ) => {
Original file line number Diff line number Diff line change @@ -32,17 +32,22 @@ export const DatagridHeaderCell = (
3232 : // non active sort field, use default order
3333 field ?. props . sortByOrder ?? 'ASC'
3434 : undefined ;
35+ const fieldLabel = field
36+ ? translateLabel ( {
37+ label :
38+ typeof field . props . label === 'string'
39+ ? field . props . label
40+ : undefined ,
41+ resource,
42+ source : field . props . source ,
43+ } )
44+ : undefined ;
3545 const sortLabel = translate ( 'ra.sort.sort_by' , {
36- field : field
37- ? translateLabel ( {
38- label :
39- typeof field . props . label === 'string'
40- ? field . props . label
41- : undefined ,
42- resource,
43- source : field . props . source ,
44- } )
45- : undefined ,
46+ field : fieldLabel ,
47+ field_lower_first :
48+ typeof fieldLabel === 'string'
49+ ? fieldLabel . charAt ( 0 ) . toLowerCase ( ) + fieldLabel . slice ( 1 )
50+ : undefined ,
4651 order : translate ( `ra.sort.${ nextSortOrder } ` ) ,
4752 _ : translate ( 'ra.action.sort' ) ,
4853 } ) ;
You can’t perform that action at this time.
0 commit comments