Skip to content

Commit

Permalink
fix(overlay): hide panel when enable inspector
Browse files Browse the repository at this point in the history
  • Loading branch information
alexzhang1030 committed May 28, 2024
1 parent b7ea97b commit 792df0a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
17 changes: 17 additions & 0 deletions packages/overlay/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,26 @@ const vueInspector = ref()
onDevToolsConnected(() => {
devtools.api.getVueInspector().then((inspector) => {
vueInspector.value = inspector
let previousPanelVisible = panelVisible.value
vueInspector.value.onEnabled = () => {
previousPanelVisible = panelVisible.value
togglePanelVisible(undefined, false)
}
vueInspector.value.onDisabled = () => {
togglePanelVisible(undefined, previousPanelVisible)
}
})
})
addEventListener('keyup', (e) => {
if (e.key.toLowerCase() === 'escape' && vueInspector.value?.enabled) {
vueInspector.value?.disable()
}
})
const vueInspectorEnabled = computed(() => {
return !!vueInspector.value
})
Expand Down
2 changes: 1 addition & 1 deletion packages/overlay/src/composables/panel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export function usePanelVisible() {
},
})

const toggleVisible = (_: unknown, state?: boolean) => {
const toggleVisible = (_?: unknown, state?: boolean) => {
visible.value = state ?? !visible.value
}

Expand Down

0 comments on commit 792df0a

Please sign in to comment.