-
Notifications
You must be signed in to change notification settings - Fork 155
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: hide navigation button when toolbar variant of AppLayout has hideNavigation #2872
Merged
Merged
Changes from all commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
75b1ee6
attempt to make page to recreate issue
dpitcock af6e0fe
fixing/adding unit tests
dpitcock cc1b787
seperation of multi-app-layout unit tests, adding params to controlle…
dpitcock edf2b29
asserting no navigation in secondary AppLayout when it has navigation…
dpitcock 8a10845
small fixes to tests, clearifying test names
dpitcock 338c2ad
fix: Multi layout register (#2906)
georgylobko bfda501
attempt to make page to recreate issue
dpitcock ac5eaa7
fixing/adding unit tests
dpitcock f46e0e6
seperation of multi-app-layout unit tests, adding params to controlle…
dpitcock 833e6ab
wrapping resolvedNavigation in useMomo hook to prevent react-hooks/ex…
dpitcock 44f76d8
removing resolvedNavigation from dependency
dpitcock e1698e1
tweaking dev page
dpitcock e137b72
removal of input ids from navigation page
dpitcock 1658ee8
returning controlled-navigation page to previous state
dpitcock c974cc0
returning isDrawerClosed to unit test
dpitcock a7f240c
removal of isDraawerClosed util
dpitcock 4eaa13c
tweaking tests
dpitcock 4d22e04
changing test to not use isVisible
dpitcock 8eb21a1
updating tests after build
dpitcock 29fd7c9
removing redundant assertion
dpitcock 9089462
Update src/app-layout/__tests__/multi-layout.test.tsx
dpitcock a4785cf
updating navitation test to ensure it does not block content when mobile
dpitcock File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
/* eslint simple-import-sort/imports: 0 */ | ||
import React from 'react'; | ||
import { describeEachAppLayout, renderComponent } from './utils'; | ||
import AppLayout from '../../../lib/components/app-layout'; | ||
|
||
import visualRefreshToolbarStyles from '../../../lib/components/app-layout/visual-refresh-toolbar/skeleton/styles.css.js'; | ||
|
||
describeEachAppLayout({ themes: ['refresh-toolbar'], sizes: ['desktop', 'mobile'] }, ({ size }) => { | ||
test('a does not hide content when navigationOpen and navigationHide is true and onNavigationChange is overwritten', () => { | ||
const mockOnNavigationChange = jest.fn(); | ||
const { wrapper } = renderComponent( | ||
<AppLayout | ||
navigationOpen={true} | ||
navigationHide={true} | ||
navigation={<>Mock Navigation</>} | ||
onNavigationChange={mockOnNavigationChange} | ||
content={<>Content</>} | ||
/> | ||
); | ||
|
||
expect(mockOnNavigationChange).toHaveBeenCalledTimes(size === 'mobile' ? 1 : 0); | ||
expect(wrapper).not.toBeNull(); | ||
expect(wrapper.findNavigation()).toBeFalsy(); | ||
expect(wrapper.findNavigationToggle()).toBeFalsy(); | ||
expect(wrapper.findByClassName(visualRefreshToolbarStyles['main-landmark'])).not.toBeNull(); | ||
expect(wrapper.findByClassName(visualRefreshToolbarStyles['unfocusable-mobile'])).toBeNull(); | ||
expect(wrapper.findByClassName(visualRefreshToolbarStyles.content)?.getElement()).toBeVisible(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
import React from 'react'; | ||
|
||
import { | ||
mergeProps, | ||
SharedProps, | ||
} from '../../../lib/components/app-layout/visual-refresh-toolbar/multi-layout'; | ||
|
||
describe('mergeMultiAppLayoutProps', () => { | ||
const mockParentNavigationToggle = jest.fn(); | ||
const mockParentActiveDrawerChange = jest.fn(); | ||
const mockParentSplitPanelToggle = jest.fn(); | ||
const ownProps: SharedProps = { | ||
forceDeduplicationType: 'primary', | ||
ariaLabels: { | ||
navigation: 'Navigation', | ||
drawers: 'Drawers', | ||
}, | ||
navigation: <div>Navigation</div>, | ||
navigationOpen: true, | ||
navigationFocusRef: React.createRef(), | ||
onNavigationToggle: mockParentNavigationToggle, | ||
breadcrumbs: <div>Breadcrumbs</div>, | ||
activeDrawerId: 'drawer1', | ||
drawers: [ | ||
{ | ||
id: 'drawer1', | ||
ariaLabels: { drawerName: 'Drawer 1' }, | ||
content: <div>Drawer 1 Content</div>, | ||
}, | ||
], | ||
onActiveDrawerChange: mockParentActiveDrawerChange, | ||
drawersFocusRef: React.createRef(), | ||
splitPanel: <div>Split Panel</div>, | ||
splitPanelToggleProps: { | ||
displayed: false, | ||
active: false, | ||
position: 'bottom', | ||
controlId: 'test', | ||
ariaLabel: 'test', | ||
}, | ||
splitPanelFocusRef: React.createRef(), | ||
onSplitPanelToggle: mockParentSplitPanelToggle, | ||
}; | ||
|
||
const additionalPropsBase: Partial<SharedProps>[] = [ | ||
{ | ||
ariaLabels: { | ||
navigation: 'New Navigation', | ||
}, | ||
drawers: [ | ||
{ | ||
id: 'drawer2', | ||
ariaLabels: { drawerName: 'Drawer 2' }, | ||
content: <div>Drawer 2 Content</div>, | ||
}, | ||
], | ||
activeDrawerId: 'drawer2', | ||
}, | ||
{ | ||
splitPanelToggleProps: { | ||
displayed: false, | ||
active: false, | ||
position: 'bottom', | ||
controlId: 'test', | ||
ariaLabel: 'test', | ||
}, | ||
}, | ||
]; | ||
|
||
it('should merge ownProps and additionalProps correctly', () => { | ||
const result = mergeProps(ownProps, additionalPropsBase); | ||
|
||
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: false, | ||
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, []); | ||
|
||
expect(result).toBeNull(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This check does not do much useful, because CSS is not loaded into JSDOM. Under the hood, it checks
getComputedStyle(element).display !== 'none'
which does not work in JSDOM. This assertion will be always passing, even if there are some obstructing stylesI would remove this assertion completely, asserting no
unfocusable-mobile
is enough