[TS] Add null checks to TreeExplorer.vue (#3166)

This commit is contained in:
Chenlei Hu
2025-03-20 13:08:22 -04:00
committed by GitHub
parent d9e62ff860
commit af0bf05883
2 changed files with 23 additions and 16 deletions

View File

@@ -1,3 +1,4 @@
import type { MenuItem } from 'primevue/menuitem'
import { ref } from 'vue'
import { useI18n } from 'vue-i18n'
@@ -55,14 +56,14 @@ export function useTreeFolderOperations(
// Generate the "Add Folder" menu item
const getAddFolderMenuItem = (
targetNode: RenderedTreeExplorerNode | null
) => {
): MenuItem => {
return {
label: t('g.newFolder'),
icon: 'pi pi-folder-plus',
command: () => {
if (targetNode) addFolderCommand(targetNode)
},
visible: targetNode && !targetNode.leaf && !!targetNode.handleAddFolder,
visible: !!targetNode && !targetNode.leaf && !!targetNode.handleAddFolder,
isAsync: false
}
}