Skip to content

Commit acd4ab4

Browse files
author
Guillaume Chau
committed
fix(ui): various bugs
1 parent a8c441c commit acd4ab4

File tree

3 files changed

+27
-14
lines changed

3 files changed

+27
-14
lines changed

packages/@vue/cli-ui-addon-webpack/src/components/WebpackAnalyzer.vue

+14-3
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363
</svg>
6464
</template>
6565

66-
<div class="described-module">
66+
<div v-if="describedModule" class="described-module">
6767
<div class="wrapper">
6868
<div class="path" v-html="modulePath"/>
6969
<div
@@ -137,6 +137,7 @@ export default {
137137
},
138138
139139
modulePath () {
140+
if (!this.describedModule) return
140141
let path = `<b>${this.describedModule.id}</b>`
141142
let module = this.describedModule
142143
while (module.parent && module !== this.currentTree) {
@@ -154,12 +155,22 @@ export default {
154155
watch: {
155156
modulesTrees: {
156157
handler (value) {
157-
if (!this.selectedChunk && value) {
158+
if (value) {
158159
const keys = Object.keys(value)
159160
if (keys.length) {
160-
this.selectedChunk = keys[0]
161+
if (!this.selectedChunk || !keys.includes(this.selectedChunk)) {
162+
if (keys.length) {
163+
this.selectedChunk = keys[0]
164+
}
165+
}
166+
this.goToHome()
167+
return
161168
}
162169
}
170+
171+
// Clear
172+
this.currentTree = null
173+
this.selectedChunk = null
163174
},
164175
immediate: true
165176
},

packages/@vue/cli-ui/src/graphql-api/connectors/plugins.js

+12-10
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ const cwd = require('./cwd')
2424
const folders = require('./folders')
2525
const prompts = require('./prompts')
2626
const progress = require('./progress')
27-
const projects = require('./projects')
2827
const logs = require('./logs')
2928
const clientAddons = require('./client-addons')
3029
const views = require('./views')
@@ -96,15 +95,18 @@ function resetPluginApi (context) {
9695
// Add views
9796
pluginApi.views.forEach(view => views.add(view, context))
9897

99-
const project = projects.getCurrent(context)
100-
if (!project) return
101-
if (projectId !== project.id) {
102-
projectId = project.id
103-
pluginApi.projectOpenHooks.forEach(fn => fn(project, projects.getLast(context)))
104-
pluginApi.project = project
105-
} else {
106-
pluginApi.pluginReloadHooks.forEach(fn => fn(project))
107-
}
98+
setTimeout(() => {
99+
const projects = require('./projects')
100+
const project = projects.getCurrent(context)
101+
if (!project) return
102+
if (projectId !== project.id) {
103+
projectId = project.id
104+
pluginApi.projectOpenHooks.forEach(fn => fn(project, projects.getLast(context)))
105+
pluginApi.project = project
106+
} else {
107+
pluginApi.pluginReloadHooks.forEach(fn => fn(project))
108+
}
109+
})
108110
}
109111

110112
function runPluginApi (id, context, fileName = 'ui') {

packages/@vue/cli-ui/src/views/ProjectTaskDetails.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ export default {
182182
},
183183
fetchPolicy: 'cache-and-network',
184184
async result ({ data, loading }) {
185-
if (!this.$_init && !loading && data && data.task.defaultView) {
185+
if (!this.$_init && !loading && data && data.task && data.task.defaultView) {
186186
this.$_init = true
187187
await this.$nextTick()
188188
this.currentView = data.task.defaultView

0 commit comments

Comments
 (0)