From 41d460574a8d7ef9b34ce6f1f0da63850064a8c8 Mon Sep 17 00:00:00 2001
From: Ryan Cogswell <287804+ryancogswell@users.noreply.github.com>
Date: Tue, 2 Jul 2019 06:13:51 -0500
Subject: [PATCH 1/4] [Menu] Fix autoFocus to work correctly with keepMounted
---
packages/material-ui/src/Menu/Menu.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/packages/material-ui/src/Menu/Menu.js b/packages/material-ui/src/Menu/Menu.js
index 4fc18e1ddb71e7..1f85ef394bfc28 100644
--- a/packages/material-ui/src/Menu/Menu.js
+++ b/packages/material-ui/src/Menu/Menu.js
@@ -53,7 +53,7 @@ const Menu = React.forwardRef(function Menu(props, ref) {
...other
} = props;
- const autoFocus = autoFocusProp !== undefined ? autoFocusProp : !disableAutoFocusItem;
+ const autoFocus = (autoFocusProp !== undefined ? autoFocusProp : !disableAutoFocusItem) && open;
const menuListActionsRef = React.useRef(null);
const firstValidItemRef = React.useRef(null);
From 8feb68642c3b8d4411872e7082201f8a548279da Mon Sep 17 00:00:00 2001
From: Ryan Cogswell <287804+ryancogswell@users.noreply.github.com>
Date: Tue, 2 Jul 2019 09:00:22 -0500
Subject: [PATCH 2/4] [test] Verify Menu focus navigation with keepMounted
---
.../material-ui/test/integration/Menu.test.js | 27 ++++++++++++++++++-
1 file changed, 26 insertions(+), 1 deletion(-)
diff --git a/packages/material-ui/test/integration/Menu.test.js b/packages/material-ui/test/integration/Menu.test.js
index 3b6a08c60e32da..be79d8b25ae38a 100644
--- a/packages/material-ui/test/integration/Menu.test.js
+++ b/packages/material-ui/test/integration/Menu.test.js
@@ -1,5 +1,5 @@
import React from 'react';
-import { assert } from 'chai';
+import { assert, expect } from 'chai';
import TestUtils from 'react-dom/test-utils';
import { createMount } from '@material-ui/core/test-utils';
import Popover from '@material-ui/core/Popover';
@@ -10,6 +10,7 @@ import { setRef } from '../../src/utils/reactHelpers';
import { stub } from 'sinon';
import PropTypes from 'prop-types';
import { createMuiTheme } from '@material-ui/core/styles';
+import { cleanup, render, fireEvent } from 'test/utils/createClientRender';
describe('