feat: contextMenuItem add hidden property (#1890)

* fix: dropdown placement bottomCenter to bottom

* feat: contextMenuItem add hidden property
This commit is contained in:
chengj 2022-05-20 18:02:23 +08:00 committed by GitHub
parent c3b5abc392
commit fe5848cf21
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 5 additions and 1 deletions

View File

@ -89,7 +89,8 @@
} }
function renderMenuItem(items: ContextMenuItem[]) { function renderMenuItem(items: ContextMenuItem[]) {
return items.map((item) => { const visibleItems = items.filter((item) => !item.hidden);
return visibleItems.map((item) => {
const { disabled, label, children, divider = false } = item; const { disabled, label, children, divider = false } = item;
const contentProps = { const contentProps = {

View File

@ -6,6 +6,7 @@ export interface Axis {
export interface ContextMenuItem { export interface ContextMenuItem {
label: string; label: string;
icon?: string; icon?: string;
hidden?: boolean;
disabled?: boolean; disabled?: boolean;
handler?: Fn; handler?: Fn;
divider?: boolean; divider?: boolean;

View File

@ -146,6 +146,7 @@
contextMenuOptions.items = menuList; contextMenuOptions.items = menuList;
} }
if (!contextMenuOptions.items?.length) return; if (!contextMenuOptions.items?.length) return;
contextMenuOptions.items = contextMenuOptions.items.filter((item) => !item.hidden);
createContextMenu(contextMenuOptions); createContextMenu(contextMenuOptions);
} }

View File

@ -141,6 +141,7 @@ export type TreeProps = ExtractPropTypes<typeof treeProps>;
export interface ContextMenuItem { export interface ContextMenuItem {
label: string; label: string;
icon?: string; icon?: string;
hidden?: boolean;
disabled?: boolean; disabled?: boolean;
handler?: Fn; handler?: Fn;
divider?: boolean; divider?: boolean;