Skip to content

Commit cff73d4

Browse files
Pages: update layout-specific config when the view is updated (#67881)
Co-authored-by: oandregal <oandregal@git.wordpress.org> Co-authored-by: youknowriad <youknowriad@git.wordpress.org>
1 parent 63b0e7f commit cff73d4

File tree

1 file changed

+7
-3
lines changed
  • packages/edit-site/src/components/post-list

1 file changed

+7
-3
lines changed

packages/edit-site/src/components/post-list/index.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ function useView( postType ) {
109109
return {
110110
...initialView,
111111
type,
112+
...defaultLayouts[ type ],
112113
};
113114
} );
114115

@@ -140,13 +141,15 @@ function useView( postType ) {
140141
// without affecting any other config.
141142
const onUrlLayoutChange = useEvent( () => {
142143
setView( ( prevView ) => {
143-
const layoutToApply = layout ?? LAYOUT_LIST;
144-
if ( layoutToApply === prevView.type ) {
144+
const newType = layout ?? LAYOUT_LIST;
145+
if ( newType === prevView.type ) {
145146
return prevView;
146147
}
148+
147149
return {
148150
...prevView,
149-
type: layout ?? LAYOUT_LIST,
151+
type: newType,
152+
...defaultLayouts[ newType ],
150153
};
151154
} );
152155
} );
@@ -168,6 +171,7 @@ function useView( postType ) {
168171
setView( {
169172
...newView,
170173
type,
174+
...defaultLayouts[ type ],
171175
} );
172176
}
173177
} );

0 commit comments

Comments
 (0)