Skip to content

Adding custom item to HierarchicalMenu with custom action #5817

Closed Answered by Ali-hd
Ali-hd asked this question in Q&A
Discussion options

You must be logged in to vote

Found a the fix to my problem!!

replace the addAllItem function with the below

const addAllItem = (
    items: HierarchicalMenuItem[],
    item: HierarchicalMenuItem
): HierarchicalMenuItem[] => {
    const hasRefinedItem = items.some((i) => i.isRefined);
    const RefinedItem = items.find((i)=>i.isRefined)
    return [
        {
            value: RefinedItem?.value || item.value,
            label: "الكل",
            count: item.count,
            isRefined: !hasRefinedItem,
            data: null,
        },
        ...items,
    ];
};

for each key used instead of doing this

key={item.value}

do this

key={item.label === "All" ? "All" : item.value}

And update the logic inside the onC…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by Ali-hd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant