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 (elastic#103715) (elastic#105647)

* 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 <[email protected]>

Co-authored-by: Kibana Machine <[email protected]>
Co-authored-by: Caroline Horn <[email protected]>

Co-authored-by: Constance <[email protected]>
Co-authored-by: Caroline Horn <[email protected]>
  • Loading branch information
3 people authored Jul 14, 2021
1 parent 9a53cfa commit 78ec8c0
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 78ec8c0

Please sign in to comment.