From 62a0f9de43727336193ed944eb004051d5be396e Mon Sep 17 00:00:00 2001 From: weryques Date: Wed, 4 Jul 2018 15:07:24 -0300 Subject: [PATCH] Fixes error when try to find index in object --- src/js/store/modules/search/mutations.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/js/store/modules/search/mutations.js b/src/js/store/modules/search/mutations.js index a003077ec..b409168e6 100644 --- a/src/js/store/modules/search/mutations.js +++ b/src/js/store/modules/search/mutations.js @@ -19,7 +19,7 @@ export const setAdvancedSearchQuery = (state, advancedSearchQuery) => { }; export const addMetaQuery = ( state, filter ) => { - state.postquery.metaquery = ( ! state.postquery.metaquery ) ? [] : state.postquery.metaquery; + state.postquery.metaquery = ( ! state.postquery.metaquery || state.postquery.metaquery.length == undefined ) ? [] : state.postquery.metaquery; let index = state.postquery.metaquery.findIndex( item => item.key === filter.metadatum_id); @@ -41,7 +41,7 @@ export const addMetaQuery = ( state, filter ) => { }; export const addTaxQuery = ( state, filter ) => { - state.postquery.taxquery = ( ! state.postquery.taxquery ) ? [] : state.postquery.taxquery; + state.postquery.taxquery = ( ! state.postquery.taxquery || state.postquery.taxquery.length == undefined ) ? [] : state.postquery.taxquery; let index = state.postquery.taxquery.findIndex( item => item.taxonomy === filter.taxonomy); if ( index >= 0 ){ Vue.set( state.postquery.taxquery, index, {