Skip to content

Commit b06d7f1

Browse files
committed
feat: state inspector: save collapsed all, fix #1391
1 parent dcaa51c commit b06d7f1

File tree

2 files changed

+17
-15
lines changed

2 files changed

+17
-15
lines changed

packages/app-frontend/src/features/inspector/StateInspector.vue

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import StateType from './StateType.vue'
33
44
import Vue from 'vue'
55
import { useDefer } from '@front/util/defer'
6+
import { getStorage, setStorage } from '@vue-devtools/shared-utils'
67
78
const keyOrder = {
89
props: 1,
@@ -25,6 +26,8 @@ const keyOrder = {
2526
'setup (other)': 8,
2627
}
2728
29+
const STORAGE_COLLAPSE_ALL = 'state-inspector.collapse-all'
30+
2831
export default {
2932
components: {
3033
StateType,
@@ -78,25 +81,22 @@ export default {
7881
},
7982
8083
watch: {
81-
state () {
82-
this.forceCollapse = null
84+
state: {
85+
handler () {
86+
this.forceCollapse = null
87+
if (getStorage(STORAGE_COLLAPSE_ALL)) {
88+
this.setExpandToAll(false)
89+
}
90+
},
91+
immediate: true,
8392
},
8493
},
8594
8695
methods: {
8796
toggle (dataType, currentExpanded, event = null) {
88-
if (event) {
89-
if (event.shiftKey) {
90-
if (currentExpanded) {
91-
this.setExpandToAll(false)
92-
this.$emit('collapse-all')
93-
return
94-
} else {
95-
this.setExpandToAll(true)
96-
this.$emit('expand-all')
97-
return
98-
}
99-
}
97+
if (event?.shiftKey) {
98+
this.setExpandToAll(!currentExpanded)
99+
return
100100
}
101101
Vue.set(this.expandedState, dataType, !currentExpanded)
102102
},
@@ -106,6 +106,8 @@ export default {
106106
this.forceCollapse = value ? 'expand' : 'collapse'
107107
Vue.set(this.expandedState, key, value)
108108
})
109+
this.$emit(value ? 'expand-all' : 'collapse-all')
110+
setStorage(STORAGE_COLLAPSE_ALL, !value)
109111
},
110112
},
111113
}

packages/app-frontend/src/locales/en.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export default {
2424
},
2525
StateInspector: {
2626
dataType: {
27-
tooltip: '[[{{keys.shift}}]] + <<mouse>>: Expand/Collapse All',
27+
tooltip: '[[{{keys.shift}}]] + <<mouse>>: Expand/Collapse All<br><div class="max-w-[200px] opacity-70">Using this shortcut will override the default toggled state and save it for next time.</div>',
2828
},
2929
filter: {
3030
tooltip: '[[{{keys.alt}}]] + [[D]] Filter state by name',

0 commit comments

Comments
 (0)