Skip to content

Commit

Permalink
Do not pass the view to the render
Browse files Browse the repository at this point in the history
  • Loading branch information
oandregal committed Dec 4, 2023
1 parent 2817be2 commit df7a9bf
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 12 deletions.
7 changes: 3 additions & 4 deletions packages/dataviews/src/view-grid.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,13 @@ export default function ViewGrid( { data, fields, view, actions, getItemId } ) {
className="dataviews-view-grid__card"
>
<div className="dataviews-view-grid__media">
{ mediaField?.render( { item, view } ) }
{ mediaField?.render( { item } ) }
</div>
<HStack
className="dataviews-view-grid__title"
justify="space-between"
>
{ primaryField?.render( { item, view } ) }
{ primaryField?.render( { item } ) }
<ItemActions
item={ item }
actions={ actions }
Expand All @@ -62,7 +62,6 @@ export default function ViewGrid( { data, fields, view, actions, getItemId } ) {
{ visibleFields.map( ( field ) => {
const renderedValue = field.render( {
item,
view,
} );
if ( ! renderedValue ) {
return null;
Expand All @@ -77,7 +76,7 @@ export default function ViewGrid( { data, fields, view, actions, getItemId } ) {
{ field.header }
</div>
<div className="dataviews-view-grid__field-value">
{ field.render( { item, view } ) }
{ field.render( { item } ) }
</div>
</VStack>
);
Expand Down
3 changes: 1 addition & 2 deletions packages/dataviews/src/view-table.js
Original file line number Diff line number Diff line change
Expand Up @@ -344,8 +344,7 @@ function ViewTable( {
const columns = useMemo( () => {
const _columns = fields.map( ( field ) => {
const { render, getValue, ...column } = field;
column.cell = ( props ) =>
render( { item: props.row.original, view } );
column.cell = ( props ) => render( { item: props.row.original } );
if ( getValue ) {
column.accessorFn = ( item ) => getValue( { item } );
}
Expand Down
6 changes: 3 additions & 3 deletions packages/edit-site/src/components/page-pages/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -194,13 +194,13 @@ export default function PagePages() {
id: 'featured-image',
header: __( 'Featured Image' ),
getValue: ( { item } ) => item.featured_media,
render: ( { item, view: currentView } ) =>
render: ( { item } ) =>
!! item.featured_media ? (
<Media
className="edit-site-page-pages__featured-image"
id={ item.featured_media }
size={
currentView.type === 'list'
view.type === 'list'
? [ 'thumbnail', 'medium', 'large', 'full' ]
: [ 'large', 'full', 'medium', 'thumbnail' ]
}
Expand Down Expand Up @@ -271,7 +271,7 @@ export default function PagePages() {
},
},
],
[ authors ]
[ authors, view ]
);

const permanentlyDeletePostAction = usePermanentlyDeletePostAction();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,11 +175,11 @@ export default function DataviewsTemplates() {
{
header: __( 'Preview' ),
id: 'preview',
render: ( { item, view: { type: viewType } } ) => {
render: ( { item } ) => {
return (
<TemplatePreview
content={ item.content.raw }
viewType={ viewType }
viewType={ view.type }
/>
);
},
Expand Down Expand Up @@ -228,7 +228,7 @@ export default function DataviewsTemplates() {
elements: authors,
},
],
[ authors ]
[ authors, view ]
);

const { shownTemplates, paginationInfo } = useMemo( () => {
Expand Down

0 comments on commit df7a9bf

Please sign in to comment.