8000 docs(NavLink): add notes about NavLink key behavior (#6793) · admirhusic/react-bootstrap@543251f · GitHub < 8000 link rel="alternate icon" class="js-site-favicon" type="image/png" href="https://github.githubassets.com/favicons/favicon.png">
[go: up one dir, main page]

Skip to content

Commit 543251f

Browse files
TJBkyletsang
andauthored
docs(NavLink): add notes about NavLink key behavior (react-bootstrap#6793)
* Update Navbar.tsx Add note to `collapseOnSelect` based on feedback in react-bootstrap#6654 * Update Navbar.tsx * Update NavLink.tsx * Update src/Navbar.tsx Co-authored-by: Kyle Tsang <6854874+kyletsang@users.noreply.github.com> --------- Co-authored-by: Kyle Tsang <6854874+kyletsang@users.noreply.github.com>
1 parent 71c7630 commit 543251f

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

src/NavLink.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,16 @@ const propTypes = {
3737
* */
3838
role: PropTypes.string,
3939

40-
/** The HTML href attribute for the `NavLink` */
40+
/**
41+
* The HTML href attribute for the `NavLink`. Used as the unique identifier
42+
* for the `NavLink` if an `eventKey` is not provided.
43+
*/
4144
href: PropTypes.string,
4245

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

src/Navbar.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,9 @@ const propTypes = {
109109
* Toggles `expanded` to `false` after the onSelect event of a descendant of a
110110
* child `<Nav>` fires. Does nothing if no `<Nav>` or `<Nav>` descendants exist.
111111
*
112+
* `<NavLink>` descendants of `<Nav>` will not trigger the `onSelect` event unless
113+
* an `eventKey` or `href` prop is defined.
114+
*
112115
* Manually controlling `expanded` via the onSelect callback is recommended instead,
113116
* for more complex operations that need to be executed after
114117
* the `select` event of `<Nav>` descendants.

0 commit comments

Comments
 (0)
0