clerk/javascript

customMenuItems not working

Closed this issue · 3 comments

Preliminary Checks

Reproduction

https://github.com/sibbng/clerk-javascript-quickstart

Publishable key

pk_test_cGF0aWVudC1idWxsZG9nLTY2LmNsZXJrLmFjY291bnRzLmRldiQ

Description

Steps to reproduce:

  1. pnpm i
  2. pnpm dev

Expected behavior:

Have a custom menu item with Hello text

Actual behavior:

No custom menu items show up

Environment

-

Hey @sibbng and sorry for the late reply
I clone your repo and I was able to see that custom menu didn't work as expected
You should define mountIcon and unmountIcon props along with menu action, e.g. href or onClick
can you try the following?

customMenuItems: [
  {
    label: "Hello",
    href: "/user",
    mountIcon: (el) => {
      el.innerHTML = "👋";
    },
    unmountIcon: (el) => {
    },
  },
],

by adding the following you will see the following custom menu item:

Screenshot 2024-10-15 at 12 05 49 PM

Feel free to ask anything if you have more questions regarding custom menu items

Yeah, it works that way. Since these properties are marked as optional in the type definitions, I thought it would work with just the label. Also, the documentation lacks an example of this. User profiles and organization profiles have examples of customPages usage, but I couldn't find an example of customMenuItems in the docs. Closing for now as it's not a bug.

@sibbng thanks for pointing this out, we'll update our docs with some JavaScript examples 🙏