diff --git a/src/api/ContextMenu.ts b/src/api/ContextMenu.ts index 6577ddc6e..bed38d7a0 100644 --- a/src/api/ContextMenu.ts +++ b/src/api/ContextMenu.ts @@ -90,20 +90,20 @@ export function removeGlobalContextMenuPatch(patch: GlobalContextMenuPatchCallba * A helper function for finding the children array of a group nested inside a context menu based on the id(s) of its children * @param id The id of the child. If an array is specified, all ids will be tried * @param children The context menu children - * @param partialCheck Whether to check if the id is partially matched + * @param matchSubstring Whether to check if the id is a substring of the child id */ -export function findGroupChildrenByChildId(id: string | string[], children: Array, partialCheck = false): Array | null { +export function findGroupChildrenByChildId(id: string | string[], children: Array, matchSubstring = false): Array | null { for (const child of children) { if (child == null) continue; if (Array.isArray(child)) { - const found = findGroupChildrenByChildId(id, child, partialCheck); + const found = findGroupChildrenByChildId(id, child, matchSubstring); if (found !== null) return found; } if ( - (Array.isArray(id) && id.some(id => partialCheck ? child.props?.id?.includes(id) : child.props?.id === id)) - || partialCheck ? child.props?.id?.includes(id) : child.props?.id === id + (Array.isArray(id) && id.some(id => matchSubstring ? child.props?.id?.includes(id) : child.props?.id === id)) + || matchSubstring ? child.props?.id?.includes(id) : child.props?.id === id ) return children; let nextChildren = child.props?.children; @@ -113,7 +113,7 @@ export function findGroupChildrenByChildId(id: string | string[], children: Arra child.props.children = nextChildren; } - const found = findGroupChildrenByChildId(id, nextChildren, true); + const found = findGroupChildrenByChildId(id, nextChildren, matchSubstring); if (found !== null) return found; } }