Skip to content

MenuItem overwrites href prop with "#" #649

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
dstop75 opened this issue May 26, 2021 · 2 comments
Closed

MenuItem overwrites href prop with "#" #649

dstop75 opened this issue May 26, 2021 · 2 comments

Comments

@dstop75
Copy link

dstop75 commented May 26, 2021

Hi! 👋

Firstly, thanks for your work on this project! 🙂

Today I used patch-package to patch [email protected] for the project I'm working on.

Problem: MenuItem overwrites href prop with "#". (We want the browser link preview to reflect the link in the menu item, because selecting it will actually navigate there, and not to the top of the current page as indicated by "#".) Please consider including this quick fix.

Here is the diff that solved my problem:

diff --git a/node_modules/react-bootstrap-typeahead/es/components/MenuItem.js b/node_modules/react-bootstrap-typeahead/es/components/MenuItem.js
index 00c67b6..fdc73f5 100644
--- a/node_modules/react-bootstrap-typeahead/es/components/MenuItem.js
+++ b/node_modules/react-bootstrap-typeahead/es/components/MenuItem.js
@@ -21,7 +21,7 @@ var BaseMenuItem = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
         active: active,
         disabled: disabled
       }, className),
-      href: "#",
+      href: props.href || "#",
       onClick: function onClick(e) {
         e.preventDefault();
         !disabled && _onClick && _onClick(e);

This issue body was partially generated by patch-package.

@ericgio
Copy link
Owner

ericgio commented Jun 3, 2021

Hi @dstop75, thanks for filing this issue! Your suggested change seems reasonable; would you mind opening a PR for it?

One thing to note is that MenuItem is provided for convenience and isn't necessarily meant to address every use case. For specific behaviors that aren't supported out of the box, consider creating your own menu item using the useItem hook or withItem HoC.

@ericgio
Copy link
Owner

ericgio commented Jul 9, 2021

Added in v5.2.0

@ericgio ericgio closed this as completed Jul 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants