Adding ability to make single Menu.Item not selectable within a Menu (for when nested Header)
See original GitHub issue- I have searched the issues of this repository and believe that this is not a duplicate.
What problem does this feature solve?
I have a situation where I am putting non-menu items into a Header with nested Menu/Items alongside regular navigation. Currently the items will highlight when clicked as-if they are the selected menu item.
I have tried the following.
- Instead of using
<Menu.Item>
, use<li className="ant-menu-item">
This causes console errors.
<Header>
<Menu theme="dark" mode="horizontal" className={styles.rightNav} selectable={false}>
<Menu.Item key="accounts">
<NavbarLink to="/accounts" icon="target" text="Accounts" />
</Menu.Item>
<li className="ant-menu-item">
<SearchInput />
</li>
</Menu>
</Header>
Warning: React does not recognize the `inlineIndent` prop on a DOM element. If you intentionally want it to appear in the DOM as a custom attribute, spell it as lowercase `inlineindent` instead. If you accidentally passed it from a parent component, remove it from the DOM element.
in li (created by Menu)
in ul (created by DOMWrap)
in DOMWrap (created by Menu)
in Menu (created by Menu)
in Menu (created by Navbar)
in div (created by Basic)
in Basic (created by Adapter)
in Adapter (created by Navbar)
in Navbar (created by App)
in div (created by BasicLayout)
in BasicLayout (created by Adapter)
in Adapter (created by App)
in App (created by Routes)
in Provider (created by Routes)
in Routes
in Router (created by BrowserRouter)
in BrowserRouter
in IntlProvider
<Menu.Items disabled={true}>
- This works, but the downside here is the default styling of disabled menu items need to be overridden.
<Header>
<Menu theme="dark" mode="horizontal" className={styles.rightNav}>
<Menu.Item key="accounts">
<NavbarLink to="/accounts" icon="target" text="Accounts" />
</Menu.Item>
<Menu.Item disabled={true}>
<SearchInput />
</Menu.Item>
</Menu>
</Header>
- Setting the Menu to selectable={false}. This works as desired for affects the other Menu.Items.
<Header>
<Menu theme="dark" mode="horizontal" className={styles.rightNav} selectable={false}>
<Menu.Item key="accounts">
<NavbarLink to="/accounts" icon="target" text="Accounts" />
</Menu.Item>
<Menu.Item>
<SearchInput />
</Menu.Item>
</Menu>
</Header>
What does the proposed API look like?
Possible solutions:
- Add a selectable attribute to the
Menu.Item
-<Menu.Item selectable={false}>
<Header>
<Menu theme="dark" mode="horizontal" className={styles.rightNav}>
<Menu.Item key="accounts">
<NavbarLink to="/accounts" icon="target" text="Accounts" />
</Menu.Item>
<Menu.Item selectable={false}>
<SearchInput />
</Menu.Item>
</Menu>
</Header>
Issue Analytics
- State:
- Created 5 years ago
- Reactions:2
- Comments:6 (2 by maintainers)
Top Results From Across the Web
How make top level menu item not have link, but have sub ...
From your WordPress dashboard, go to "Appearance -> Menus" · In the "Edit Menus" tab, select "Custom Links" · For the URL, Enter...
Read more >How to Make a Non Clickable Menu Item in Wordpress
1) In your APPEARANCE > MENUS, make sure you go to “Screen Options” (top right hand of your screen). Make sure “CSS Classes”...
Read more >Header: Create a multi-column nested menu (Mega Navigation)
Add menu items to include in the new 'Store' drop-down menu. Click 'Add menu item', enter the name of the menu item, and...
Read more >Targeting Menu Elements with Submenus in a Navigation Bar
The common way to address this issue, is to simply add a class to the <li> s that contain <ul> s (sub menus)...
Read more >How to Add Titles in WordPress Menu Without Linking to a Page
For example, you can have a categories dropdown where you want the title text to be 'categories' for the menu but don't need...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
The CSS property
pointer-events
set tonone
makes the component ignore mouse events without altering the style of the cursor.^ is there a solution