Skip to content

Commit

Permalink
fix(SideNav): pass additional props provided to SideNav to the render…
Browse files Browse the repository at this point in the history
…ed nav element (#7960)

* fix(SideNav): pass additional props as other to rendered component

* Apply suggestions from code review

Co-authored-by: TJ Egan <tw15egan@gmail.com>

* chore(tests): update snapshots

* chore(SideNav): comment out unused default props

* chore(tests): update snapshots

Co-authored-by: TJ Egan <tw15egan@gmail.com>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
  • Loading branch information
3 people committed Mar 6, 2021
1 parent 43b063b commit 13f1e36
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6998,7 +6998,6 @@ Map {
"isChildOfHeader": true,
"isFixedNav": false,
"isPersistent": true,
"translateById": [Function],
},
"propTypes": Object {
"addFocusListeners": Object {
Expand Down
19 changes: 11 additions & 8 deletions packages/react/src/components/UIShell/SideNav.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ const SideNav = React.forwardRef(function SideNav(props, ref) {
isPersistent,
addFocusListeners,
addMouseListeners,
...other
} = props;

const { current: controlled } = useRef(expandedProp !== undefined);
Expand Down Expand Up @@ -120,21 +121,23 @@ const SideNav = React.forwardRef(function SideNav(props, ref) {
ref={ref}
className={`${prefix}--side-nav__navigation ${className}`}
{...accessibilityLabel}
{...eventHandlers}>
{...eventHandlers}
{...other}>
{childrenToRender}
</nav>
</>
);
});

SideNav.defaultProps = {
translateById: (id) => {
const translations = {
'carbon.sidenav.state.open': 'Close',
'carbon.sidenav.state.closed': 'Open',
};
return translations[id];
},
// TO-DO: comment back in when footer is added for rails
// translateById: (id) => {
// const translations = {
// 'carbon.sidenav.state.open': 'Close',
// 'carbon.sidenav.state.closed': 'Open',
// };
// return translations[id];
// },
defaultExpanded: false,
isChildOfHeader: true,
isFixedNav: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ exports[`SideNav should render 1`] = `
isChildOfHeader={true}
isFixedNav={false}
isPersistent={true}
translateById={[Function]}
>
<div
className="bx--side-nav__overlay"
Expand Down

0 comments on commit 13f1e36

Please sign in to comment.