diff --git a/src/app-layout/__tests__/multi-layout-props.test.tsx b/src/app-layout/__tests__/multi-layout-props.test.tsx index 74b3fc1ba5..4207ecbb38 100644 --- a/src/app-layout/__tests__/multi-layout-props.test.tsx +++ b/src/app-layout/__tests__/multi-layout-props.test.tsx @@ -67,6 +67,9 @@ describe('mergeMultiAppLayoutProps', () => { id: 'drawer-global', ariaLabels: { drawerName: 'Global Drawer' }, content:
Global Drawer Content
, + trigger: { + iconName: 'add-plus', + }, }, ], onActiveGlobalDrawersChange: mockParentActiveGlobalDrawerChange, @@ -117,12 +120,59 @@ describe('mergeMultiAppLayoutProps', () => { id: 'drawer-global', ariaLabels: { drawerName: 'Global Drawer' }, content:
Global Drawer Content
, + trigger: { + iconName: 'add-plus', + }, }, ], onActiveGlobalDrawersChange: mockParentActiveGlobalDrawerChange, }); }); + it('should merge ownProps and additionalProps (triggerless global drawers)', () => { + const result = mergeProps(ownProps, [ + { + ...additionalPropsBase[0], + globalDrawers: [ + { + id: 'drawer-global', + ariaLabels: { drawerName: 'Global Drawer' }, + content:
Global Drawer Content
, + }, + ], + }, + additionalPropsBase[1], + ]); + + expect(result).toEqual({ + //asserting new aria labels overwrite existing yet preserve others + ariaLabels: { + navigation: 'New Navigation', + drawers: 'Drawers', + }, + hasNavigation: true, + navigationOpen: true, + navigationFocusRef: ownProps.navigationFocusRef, + onNavigationToggle: mockParentNavigationToggle, + hasBreadcrumbsPortal: true, + hasSplitPanel: true, + splitPanelToggleProps: { + displayed: true, + active: false, + position: 'bottom', + controlId: 'test', + ariaLabel: 'test', + }, + splitPanelFocusRef: ownProps.splitPanelFocusRef, + onSplitPanelToggle: mockParentSplitPanelToggle, + //asserting the ownProps drawer is not overwritten + activeDrawerId: ownProps.activeDrawerId, + drawers: ownProps.drawers, + drawersFocusRef: ownProps.drawersFocusRef, + onActiveDrawerChange: mockParentActiveDrawerChange, + }); + }); + it('should return null if no fields are defined, except ariaLabels', () => { const result = mergeProps({ ariaLabels: {} } as SharedProps, []); diff --git a/src/app-layout/visual-refresh-toolbar/state/props-merger.ts b/src/app-layout/visual-refresh-toolbar/state/props-merger.ts index 1853ec2715..37299c2b4a 100644 --- a/src/app-layout/visual-refresh-toolbar/state/props-merger.ts +++ b/src/app-layout/visual-refresh-toolbar/state/props-merger.ts @@ -31,7 +31,11 @@ export const mergeProps: MergeProps = (ownProps, additionalProps) => { toolbar.drawersFocusRef = props.drawersFocusRef; toolbar.onActiveDrawerChange = props.onActiveDrawerChange; } - if (props.globalDrawers && !checkAlreadyExists(!!toolbar.globalDrawers, 'globalDrawers')) { + if ( + props.globalDrawers && + props.globalDrawers.some(drawer => drawer.trigger) && + !checkAlreadyExists(!!toolbar.globalDrawers, 'globalDrawers') + ) { toolbar.globalDrawersFocusControl = props.globalDrawersFocusControl; toolbar.globalDrawers = props.globalDrawers; toolbar.activeGlobalDrawersIds = props.activeGlobalDrawersIds;