Skip to content

Commit b3d41b8

Browse files
davisionfago
andauthored
VAL-164 - Fix setMenu mutation to preserve reactivity (#48)
* VAL-164 - Fix setMenu mutation * Add comment explaining changes. Co-authored-by: Wolfgang Ziegler <[email protected]>
1 parent a4c0bc4 commit b3d41b8

File tree

3 files changed

+3272
-4098
lines changed

3 files changed

+3272
-4098
lines changed

lib/plugin.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,7 @@ const storeModule = {
5858
settings: {}
5959
},
6060
messages: [],
61-
menus: {
62-
main: [],
63-
footer: []
64-
}
61+
menus: {}
6562
}),
6663
getters: {},
6764
mutations: {
@@ -106,7 +103,9 @@ const storeModule = {
106103
state.messages.push(message)
107104
},
108105
setMenu (state, { name, data }) {
109-
state.menus[name] = data
106+
// Update the menu in a way it works well with Vue's reactivity.
107+
// See https://vuex.vuejs.org/guide/mutations.html#mutations-follow-vue-s-reactivity-rules
108+
state.menus = { ...state.menus, [name]: data }
110109
}
111110
},
112111
actions: {

0 commit comments

Comments
 (0)