Skip to content

Commit c627fdc

Browse files
authored
Merge pull request #324 from nextcloud/fix/noid/unmount-vue3
Fix unmounting the sidebar tab component in Vue 3
2 parents 06c04dc + 563f319 commit c627fdc

4 files changed

Lines changed: 14 additions & 12 deletions

File tree

img/screenshot_1.jpg

21.5 KB
Loading

img/screenshot_2.jpg

69.4 KB
Loading

img/screenshot_3.jpg

75.8 KB
Loading

src/approvalTab.js

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,34 +9,36 @@ import { translate as t, translatePlural as n } from '@nextcloud/l10n'
99
import ApprovalTab from './views/ApprovalTab.vue'
1010

1111
// Init approval tab component
12-
let TabInstance = null
12+
let tabView = null
13+
let tabApp = null
1314
const approvalTab = new OCA.Files.Sidebar.Tab({
1415
id: 'approval',
1516
name: t('approval', 'Approval'),
1617
iconSvg: ApprovalSvgIcon,
1718

1819
async mount(el, fileInfo, context) {
19-
if (TabInstance) {
20-
TabInstance.unmount()
20+
if (tabApp !== null) {
21+
tabApp.unmount()
2122
}
22-
const Tab = createApp(ApprovalTab)
23-
Tab.mixin({ methods: { t, n } })
23+
tabApp = createApp(ApprovalTab)
24+
tabApp.mixin({ methods: { t, n } })
2425

25-
TabInstance = Tab.mount(el)
26+
tabView = tabApp.mount(el)
2627
// Only mount after we have all the info we need
27-
await TabInstance.update(fileInfo)
28+
await tabView.update(fileInfo)
2829
},
2930

3031
update(fileInfo) {
31-
if (TabInstance && typeof TabInstance.update === 'function') {
32-
TabInstance.update(fileInfo)
32+
if (tabView && typeof tabView.update === 'function') {
33+
tabView.update(fileInfo)
3334
}
3435
},
3536

3637
destroy() {
37-
if (TabInstance) {
38-
TabInstance.unmount()
39-
TabInstance = null
38+
if (tabApp) {
39+
tabApp.unmount()
40+
tabView = null
41+
tabApp = null
4042
}
4143
},
4244
})

0 commit comments

Comments
 (0)