Skip to content

Commit

Permalink
Pages: update layout-specific config when the view is updated (#67881)
Browse files Browse the repository at this point in the history
Co-authored-by: oandregal <oandregal@git.wordpress.org>
Co-authored-by: youknowriad <youknowriad@git.wordpress.org>
  • Loading branch information
3 people authored Dec 12, 2024
1 parent 63b0e7f commit cff73d4
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions packages/edit-site/src/components/post-list/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ function useView( postType ) {
return {
...initialView,
type,
...defaultLayouts[ type ],
};
} );

Expand Down Expand Up @@ -140,13 +141,15 @@ function useView( postType ) {
// without affecting any other config.
const onUrlLayoutChange = useEvent( () => {
setView( ( prevView ) => {
const layoutToApply = layout ?? LAYOUT_LIST;
if ( layoutToApply === prevView.type ) {
const newType = layout ?? LAYOUT_LIST;
if ( newType === prevView.type ) {
return prevView;
}

return {
...prevView,
type: layout ?? LAYOUT_LIST,
type: newType,
...defaultLayouts[ newType ],
};
} );
} );
Expand All @@ -168,6 +171,7 @@ function useView( postType ) {
setView( {
...newView,
type,
...defaultLayouts[ type ],
} );
}
} );
Expand Down

1 comment on commit cff73d4

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Flaky tests detected in cff73d4.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/12304129041
📝 Reported issues:

Please sign in to comment.