Commit fe5848cf214f27b9807384870259982559b8f0e8
Committed by
GitHub
1 parent
c3b5abc3
feat: contextMenuItem add hidden property (#1890)
* fix: dropdown placement bottomCenter to bottom * feat: contextMenuItem add hidden property
Showing
4 changed files
with
5 additions
and
1 deletions
src/components/ContextMenu/src/ContextMenu.vue
@@ -89,7 +89,8 @@ | @@ -89,7 +89,8 @@ | ||
89 | } | 89 | } |
90 | 90 | ||
91 | function renderMenuItem(items: ContextMenuItem[]) { | 91 | function renderMenuItem(items: ContextMenuItem[]) { |
92 | - return items.map((item) => { | 92 | + const visibleItems = items.filter((item) => !item.hidden); |
93 | + return visibleItems.map((item) => { | ||
93 | const { disabled, label, children, divider = false } = item; | 94 | const { disabled, label, children, divider = false } = item; |
94 | 95 | ||
95 | const contentProps = { | 96 | const contentProps = { |
src/components/ContextMenu/src/typing.ts
@@ -6,6 +6,7 @@ export interface Axis { | @@ -6,6 +6,7 @@ export interface Axis { | ||
6 | export interface ContextMenuItem { | 6 | export interface ContextMenuItem { |
7 | label: string; | 7 | label: string; |
8 | icon?: string; | 8 | icon?: string; |
9 | + hidden?: boolean; | ||
9 | disabled?: boolean; | 10 | disabled?: boolean; |
10 | handler?: Fn; | 11 | handler?: Fn; |
11 | divider?: boolean; | 12 | divider?: boolean; |
src/components/Tree/src/Tree.vue
@@ -146,6 +146,7 @@ | @@ -146,6 +146,7 @@ | ||
146 | contextMenuOptions.items = menuList; | 146 | contextMenuOptions.items = menuList; |
147 | } | 147 | } |
148 | if (!contextMenuOptions.items?.length) return; | 148 | if (!contextMenuOptions.items?.length) return; |
149 | + contextMenuOptions.items = contextMenuOptions.items.filter((item) => !item.hidden); | ||
149 | createContextMenu(contextMenuOptions); | 150 | createContextMenu(contextMenuOptions); |
150 | } | 151 | } |
151 | 152 |
src/components/Tree/src/tree.ts
@@ -141,6 +141,7 @@ export type TreeProps = ExtractPropTypes<typeof treeProps>; | @@ -141,6 +141,7 @@ export type TreeProps = ExtractPropTypes<typeof treeProps>; | ||
141 | export interface ContextMenuItem { | 141 | export interface ContextMenuItem { |
142 | label: string; | 142 | label: string; |
143 | icon?: string; | 143 | icon?: string; |
144 | + hidden?: boolean; | ||
144 | disabled?: boolean; | 145 | disabled?: boolean; |
145 | handler?: Fn; | 146 | handler?: Fn; |
146 | divider?: boolean; | 147 | divider?: boolean; |