Skip to content
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

docs: Add notes about NavLink key behavior #6793

Merged
merged 4 commits into from
Jun 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/NavLink.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,16 @@ const propTypes = {
* */
role: PropTypes.string,

/** The HTML href attribute for the `NavLink` */
/**
* The HTML href attribute for the `NavLink`. Used as the unique identifier
* for the `NavLink` if an `eventKey` is not provided.
*/
href: PropTypes.string,

/**
* Uniquely identifies the `NavItem` amongst its siblings,
* used to determine and control the active state of the parent `Nav`
* as well as onSelect behavior of a parent `Navbar`.
*/
eventKey: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),

Expand Down
3 changes: 3 additions & 0 deletions src/Navbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,9 @@ const propTypes = {
* Toggles `expanded` to `false` after the onSelect event of a descendant of a
* child `<Nav>` fires. Does nothing if no `<Nav>` or `<Nav>` descendants exist.
*
* `<NavLink>` descendants of `<Nav>` will not trigger the `onSelect` event unless
* an `eventKey` or `href` prop is defined.
*
* Manually controlling `expanded` via the onSelect callback is recommended instead,
* for more complex operations that need to be executed after
* the `select` event of `<Nav>` descendants.
Expand Down