Skip to content

Commit

Permalink
[KibanaPageTemplate] Fix custom sidebar classes overriding kbnPageTem…
Browse files Browse the repository at this point in the history
…plate class (#103715)

* Fix .kbnPageTemplate__pageSideBar getting overriden by passed classes

- due to it existing in ...rest, and ...rest coming after pageSideBarProps

* Add test

* Fix `sideBarClasses`

Co-authored-by: Caroline Horn <549577+cchaos@users.noreply.github.com>

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
Co-authored-by: Caroline Horn <549577+cchaos@users.noreply.github.com>
  • Loading branch information
3 people authored Jul 14, 2021
1 parent 5a08cae commit 99d21b5
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -125,4 +125,20 @@ describe('KibanaPageTemplate', () => {
);
expect(component).toMatchSnapshot();
});

test('render sidebar classes', () => {
const component = shallow(
<KibanaPageTemplate
solutionNav={{
name: 'Solution',
icon: 'solution',
items: navItems,
}}
pageSideBarProps={{ className: 'customClass' }}
/>
);
expect(component.prop('pageSideBarProps').className).toEqual(
'kbnPageTemplate__pageSideBar customClass'
);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ export const KibanaPageTemplate: FunctionComponent<KibanaPageTemplateProps> = ({
isEmptyState,
restrictWidth = true,
pageSideBar,
pageSideBarProps,
solutionNav,
...rest
}) => {
Expand Down Expand Up @@ -117,8 +118,8 @@ export const KibanaPageTemplate: FunctionComponent<KibanaPageTemplateProps> = ({
pageSideBar={pageSideBar}
pageSideBarProps={{
paddingSize: solutionNav ? 'none' : 'l',
...rest.pageSideBarProps,
className: classNames(sideBarClasses, rest.pageSideBarProps?.className),
...pageSideBarProps,
className: classNames(sideBarClasses, pageSideBarProps?.className),
}}
{...rest}
>
Expand Down

0 comments on commit 99d21b5

Please sign in to comment.