Skip to content

Commit 9e4cb19

Browse files
authored
fix(android-needs-review): make left nav panel dismiss on escape and on click out of menu (#3693)
#### Description of changes Addresses #3692. #### Pull request checklist <!-- If a checklist item is not applicable to this change, write "n/a" in the checkbox --> - [x] Addresses an existing issue: #3692. - [x] Ran `yarn fastpass` - [x] Added/updated relevant unit test(s) (and ran `yarn test`) - [x] Verified code coverage for the changes made. Check coverage report at: `<rootDir>/test-results/unit/coverage` - [x] PR title *AND* final merge commit title both start with a semantic tag (`fix:`, `chore:`, `feat(feature-name):`, `refactor:`). See `CONTRIBUTING.md`. - [ ] (UI changes only) Added screenshots/GIFs to description above - [x] (UI changes only) Verified usability with NVDA/JAWS
1 parent 45abf45 commit 9e4cb19

File tree

3 files changed

+16
-2
lines changed

3 files changed

+16
-2
lines changed

src/electron/views/left-nav/fluent-left-nav.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,11 @@ export const FluentLeftNav = NamedFC<FluentLeftNavProps>('LeftNav', props => {
3737
layerProps={{ className: styles.leftNavPanelHost }}
3838
className={styles.leftNavPanel}
3939
isOpen={isNavOpen}
40-
isLightDismiss
4140
hasCloseButton={false}
4241
onRenderNavigationContent={() => null}
4342
onRenderNavigation={() => null}
4443
type={PanelType.customNear}
44+
onDismiss={() => setSideNavOpen(false)}
4545
>
4646
<div className={styles.navMenuContainer}>
4747
<FastPassLeftNavHamburgerButton

src/tests/unit/tests/electron/views/left-nav/__snapshots__/fluent-left-nav.test.tsx.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@ exports[`FluentLeftNav render left nav inside panel 1`] = `
1212
className="leftNavPanel"
1313
hasCloseButton={false}
1414
innerPanelAutomationId="fluent-left-nav"
15-
isLightDismiss={true}
1615
isOpen={true}
1716
layerProps={
1817
Object {
1918
"className": "leftNavPanelHost",
2019
}
2120
}
21+
onDismiss={[Function]}
2222
onRenderNavigation={[Function]}
2323
onRenderNavigationContent={[Function]}
2424
type={8}

src/tests/unit/tests/electron/views/left-nav/fluent-left-nav.test.tsx

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// Licensed under the MIT License.
33

44
import { FastPassLeftNavHamburgerButton } from 'common/components/expand-collapse-left-nav-hamburger-button';
5+
import { GenericPanel } from 'DetailsView/components/generic-panel';
56
import { NarrowModeStatus } from 'DetailsView/components/narrow-mode-detector';
67
import {
78
FluentLeftNav,
@@ -10,6 +11,7 @@ import {
1011
} from 'electron/views/left-nav/fluent-left-nav';
1112
import { shallow } from 'enzyme';
1213
import * as React from 'react';
14+
import { Mock, MockBehavior } from 'typemoq';
1315

1416
describe('FluentLeftNav', () => {
1517
let props: FluentLeftNavProps;
@@ -45,4 +47,16 @@ describe('FluentLeftNav', () => {
4547
const testSubject = shallow(<FluentLeftNav {...props} />);
4648
expect(testSubject.getElement()).toMatchSnapshot();
4749
});
50+
51+
test('dismissing the panel uses setSideNavOpen(false)', () => {
52+
const setSideNavOpenMock = Mock.ofInstance((state: boolean) => {}, MockBehavior.Strict);
53+
props.setSideNavOpen = setSideNavOpenMock.object;
54+
const testSubject = shallow(<FluentLeftNav {...props} />);
55+
56+
setSideNavOpenMock.setup(m => m(false)).verifiable();
57+
58+
testSubject.find(GenericPanel).prop('onDismiss')();
59+
60+
setSideNavOpenMock.verifyAll();
61+
});
4862
});

0 commit comments

Comments
 (0)