Skip to content
This repository has been archived by the owner on Mar 1, 2024. It is now read-only.

Commit

Permalink
useExact for subNavItems (#412)
Browse files Browse the repository at this point in the history
useExact for subNavItems
  • Loading branch information
jonthomp committed Jun 1, 2019
2 parents 944ef10 + 002b30b commit 542f1a3
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 2 deletions.
1 change: 1 addition & 0 deletions example/src/SiteWrapper.react.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ type subNavItem = {|
+to?: string,
+icon?: string,
+LinkComponent?: React.ElementType,
+useExact?: boolean,
|};

type navItem = {|
Expand Down
7 changes: 6 additions & 1 deletion src/components/Dropdown/DropdownItem.react.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ type Props = {|
* onClick handler
*/
+onClick?: (event: SyntheticMouseEvent<*>) => mixed,
/**
* Whether or not to pass "exact" property to underlying NavLink component
*/
+useExact?: boolean,
|};

/**
Expand All @@ -52,6 +56,7 @@ function DropdownItem({
to,
RootComponent,
onClick,
useExact,
}: Props): React.Node {
const classes = cn({ "dropdown-item": true }, className);
const childrenForAll = (
Expand All @@ -71,7 +76,7 @@ function DropdownItem({
</React.Fragment>
);
return RootComponent ? (
<RootComponent className={classes} to={to} onClick={onClick}>
<RootComponent className={classes} to={to} onClick={onClick} exact={useExact}>
{childrenForAll}
</RootComponent>
) : (
Expand Down
1 change: 1 addition & 0 deletions src/components/Nav/Nav.react.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export type subNavItem = {|
+to?: string,
+icon?: string,
+LinkComponent?: React.ElementType,
+useExact?: boolean,
|};

type navItem = {|
Expand Down
1 change: 1 addition & 0 deletions src/components/Nav/NavItem.react.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ class NavItem extends React.Component<Props, State> {
to={a.to}
icon={a.icon}
LinkComponent={a.LinkComponent}
useExact={a.useExact}
/>
))) ||
children}
Expand Down
4 changes: 3 additions & 1 deletion src/components/Nav/NavSubItem.react.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ type Props = {|
+to?: string,
+icon?: string,
+value?: string,
+useExact?: boolean,
|};

function NavSubItem({
Expand All @@ -19,9 +20,10 @@ function NavSubItem({
icon,
hasSubNav,
value,
useExact,
}: Props): React.Node {
return (
<Dropdown.Item to={to} icon={icon} RootComponent={LinkComponent}>
<Dropdown.Item to={to} icon={icon} RootComponent={LinkComponent} useExact={useExact || false}>
{value || children}
</Dropdown.Item>
);
Expand Down
1 change: 1 addition & 0 deletions src/components/Site/SiteNav.react.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ type subNavItem = {|
+to?: string,
+icon?: string,
+LinkComponent?: React.ElementType,
+useExact?: boolean,
|};

type navItem = {|
Expand Down

0 comments on commit 542f1a3

Please sign in to comment.