Handles invalid orderby 'name' in the store.

This commit is contained in:
mateuswetah 2021-12-10 12:04:17 -03:00
parent 479e153700
commit c627bed216
1 changed files with 5 additions and 1 deletions

View File

@ -96,7 +96,11 @@ export const setOrderBy = ({ state, commit }, orderBy ) => {
commit('removePostQueryAttribute', 'metakey');
commit('removePostQueryAttribute', 'metatype');
if (orderBy.metakey) {
// This first if is to handle situations where a collection was created
// with the invalid default of 'name'
if (orderBy == 'name' || (order.metakey && order.metakey == 'name') ) {
commit('setPostQueryAttribute', { attr: 'orderby', value: 'date' } );
} else if (orderBy.metakey) {
Object.keys(orderBy).forEach((paramKey) => {
commit('setPostQueryAttribute', { attr: paramKey, value: orderBy[paramKey] });
});