From 8f381290f74148da9b3ce335c6b8c4978b6b79da Mon Sep 17 00:00:00 2001 From: Marcus Silva Date: Wed, 24 Mar 2021 16:48:56 -0300 Subject: [PATCH] fix: reset grid error --- src/store.js | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/src/store.js b/src/store.js index 23b2ccb..23c93f6 100644 --- a/src/store.js +++ b/src/store.js @@ -83,8 +83,17 @@ export default new Vuex.Store({ updateRowGap(state, payload) { state.rowgap = payload; }, - resetGrid(state, payload) { - state.childarea = []; + resetGrid(state, payload) { + Object.assign(state, { + columns: 5, + rows: 5, + columngap: 0, + rowgap: 0, + childarea: [], + }); + + resetDirectionUnit(state, 'colArr') + resetDirectionUnit(state, 'rowArr') } } }); @@ -95,3 +104,11 @@ const createArr = (direction, arr) => { arr.push({ unit: "1fr" }); } }; + +const resetDirectionUnit = (state, direction) => { + state[direction].forEach(col => { + if(col.unit !== "1fr") { + col.unit = '1fr' + } + }) +}