Skip to content

Commit 80fc767

Browse files
Revert "[Menu] Deprecate transition onX props (#22213)"
This reverts commit 076a5fb.
1 parent 688e248 commit 80fc767

File tree

4 files changed

+16
-149
lines changed

4 files changed

+16
-149
lines changed

docs/pages/api-docs/menu.md

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,16 +35,15 @@ The `MuiMenu` name can be used for providing [default props](/customization/glob
3535
| <span class="prop-name">disableAutoFocusItem</span> | <span class="prop-type">bool</span> | <span class="prop-default">false</span> | When opening the menu will not focus the active item but the `[role="menu"]` unless `autoFocus` is also set to `false`. Not using the default means not following WAI-ARIA authoring practices. Please be considerate about possible accessibility implications. |
3636
| <span class="prop-name">MenuListProps</span> | <span class="prop-type">object</span> | <span class="prop-default">{}</span> | Props applied to the [`MenuList`](/api/menu-list/) element. |
3737
| <span class="prop-name">onClose</span> | <span class="prop-type">func</span> | | Callback fired when the component requests to be closed.<br><br>**Signature:**<br>`function(event: object, reason: string) => void`<br>*event:* The event source of the callback.<br>*reason:* Can be: `"escapeKeyDown"`, `"backdropClick"`, `"tabKeyDown"`. |
38-
| ~~<span class="prop-name">onEnter</span>~~ | <span class="prop-type">func</span> | | *Deprecated*. Use the `TransitionProps` prop instead.<br><br>Callback fired before the Menu enters. |
39-
| ~~<span class="prop-name">onEntered</span>~~ | <span class="prop-type">func</span> | | *Deprecated*. Use the `TransitionProps` prop instead.<br><br>Callback fired when the Menu has entered. |
40-
| ~~<span class="prop-name">onEntering</span>~~ | <span class="prop-type">func</span> | | *Deprecated*. Use the `TransitionProps` prop instead.<br><br>Callback fired when the Menu is entering. |
41-
| ~~<span class="prop-name">onExit</span>~~ | <span class="prop-type">func</span> | | *Deprecated*. Use the `TransitionProps` prop instead.<br><br>Callback fired before the Menu exits. |
42-
| ~~<span class="prop-name">onExited</span>~~ | <span class="prop-type">func</span> | | *Deprecated*. Use the `TransitionProps` prop instead.<br><br>Callback fired when the Menu has exited. |
43-
| ~~<span class="prop-name">onExiting</span>~~ | <span class="prop-type">func</span> | | *Deprecated*. Use the `TransitionProps` prop instead.<br><br>Callback fired when the Menu is exiting. |
38+
| <span class="prop-name">onEnter</span> | <span class="prop-type">func</span> | | Callback fired before the Menu enters. |
39+
| <span class="prop-name">onEntered</span> | <span class="prop-type">func</span> | | Callback fired when the Menu has entered. |
40+
| <span class="prop-name">onEntering</span> | <span class="prop-type">func</span> | | Callback fired when the Menu is entering. |
41+
| <span class="prop-name">onExit</span> | <span class="prop-type">func</span> | | Callback fired before the Menu exits. |
42+
| <span class="prop-name">onExited</span> | <span class="prop-type">func</span> | | Callback fired when the Menu has exited. |
43+
| <span class="prop-name">onExiting</span> | <span class="prop-type">func</span> | | Callback fired when the Menu is exiting. |
4444
| <span class="prop-name required">open<abbr title="required">*</abbr></span> | <span class="prop-type">bool</span> | | If `true`, the menu is visible. |
4545
| <span class="prop-name">PopoverClasses</span> | <span class="prop-type">object</span> | | `classes` prop applied to the [`Popover`](/api/popover/) element. |
4646
| <span class="prop-name">transitionDuration</span> | <span class="prop-type">'auto'<br>&#124;&nbsp;number<br>&#124;&nbsp;{ appear?: number, enter?: number, exit?: number }</span> | <span class="prop-default">'auto'</span> | The length of the transition in `ms`, or 'auto' |
47-
| <span class="prop-name">TransitionProps</span> | <span class="prop-type">object</span> | <span class="prop-default">{}</span> | Props applied to the transition element. By default, the element is based on this [`Transition`](http://reactcommunity.org/react-transition-group/transition) component. |
4847
| <span class="prop-name">variant</span> | <span class="prop-type">'menu'<br>&#124;&nbsp;'selectedMenu'</span> | <span class="prop-default">'selectedMenu'</span> | The variant to use. Use `menu` to prevent selected items from impacting the initial focus and the vertical alignment relative to the anchor element. |
4948

5049
The `ref` is forwarded to the root element.

packages/material-ui/src/Menu/Menu.d.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -84,11 +84,6 @@ export interface MenuProps
8484
* The length of the transition in `ms`, or 'auto'
8585
*/
8686
transitionDuration?: TransitionProps['timeout'] | 'auto';
87-
/**
88-
* Props applied to the transition element.
89-
* By default, the element is based on this [`Transition`](http://reactcommunity.org/react-transition-group/transition) component.
90-
*/
91-
TransitionProps?: TransitionProps;
9287
/**
9388
* The variant to use. Use `menu` to prevent selected items from impacting the initial focus
9489
* and the vertical alignment relative to the anchor element.

packages/material-ui/src/Menu/Menu.js

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import MenuList from '../MenuList';
99
import * as ReactDOM from 'react-dom';
1010
import setRef from '../utils/setRef';
1111
import useTheme from '../styles/useTheme';
12-
import deprecatedPropType from '../utils/deprecatedPropType';
1312

1413
const RTL_ORIGIN = {
1514
vertical: 'top',
@@ -46,12 +45,11 @@ const Menu = React.forwardRef(function Menu(props, ref) {
4645
disableAutoFocusItem = false,
4746
MenuListProps = {},
4847
onClose,
49-
onEntering: onEnteringProp,
48+
onEntering,
5049
open,
5150
PaperProps = {},
5251
PopoverClasses,
5352
transitionDuration = 'auto',
54-
TransitionProps: { onEntering, ...TransitionProps } = {},
5553
variant = 'selectedMenu',
5654
...other
5755
} = props;
@@ -68,9 +66,7 @@ const Menu = React.forwardRef(function Menu(props, ref) {
6866
if (menuListActionsRef.current) {
6967
menuListActionsRef.current.adjustStyleForScrollbar(element, theme);
7068
}
71-
if (onEnteringProp) {
72-
onEnteringProp(element, isAppearing);
73-
}
69+
7470
if (onEntering) {
7571
onEntering(element, isAppearing);
7672
}
@@ -139,7 +135,7 @@ const Menu = React.forwardRef(function Menu(props, ref) {
139135
getContentAnchorEl={getContentAnchorEl}
140136
classes={PopoverClasses}
141137
onClose={onClose}
142-
TransitionProps={{ onEntering: handleEntering, ...TransitionProps }}
138+
TransitionProps={{ onEntering: handleEntering }}
143139
anchorOrigin={theme.direction === 'rtl' ? RTL_ORIGIN : LTR_ORIGIN}
144140
transformOrigin={theme.direction === 'rtl' ? RTL_ORIGIN : LTR_ORIGIN}
145141
PaperProps={{
@@ -220,27 +216,27 @@ Menu.propTypes = {
220216
/**
221217
* Callback fired before the Menu enters.
222218
*/
223-
onEnter: deprecatedPropType(PropTypes.func, 'Use the `TransitionProps` prop instead.'),
219+
onEnter: PropTypes.func,
224220
/**
225221
* Callback fired when the Menu has entered.
226222
*/
227-
onEntered: deprecatedPropType(PropTypes.func, 'Use the `TransitionProps` prop instead.'),
223+
onEntered: PropTypes.func,
228224
/**
229225
* Callback fired when the Menu is entering.
230226
*/
231-
onEntering: deprecatedPropType(PropTypes.func, 'Use the `TransitionProps` prop instead.'),
227+
onEntering: PropTypes.func,
232228
/**
233229
* Callback fired before the Menu exits.
234230
*/
235-
onExit: deprecatedPropType(PropTypes.func, 'Use the `TransitionProps` prop instead.'),
231+
onExit: PropTypes.func,
236232
/**
237233
* Callback fired when the Menu has exited.
238234
*/
239-
onExited: deprecatedPropType(PropTypes.func, 'Use the `TransitionProps` prop instead.'),
235+
onExited: PropTypes.func,
240236
/**
241237
* Callback fired when the Menu is exiting.
242238
*/
243-
onExiting: deprecatedPropType(PropTypes.func, 'Use the `TransitionProps` prop instead.'),
239+
onExiting: PropTypes.func,
244240
/**
245241
* If `true`, the menu is visible.
246242
*/
@@ -265,11 +261,6 @@ Menu.propTypes = {
265261
exit: PropTypes.number,
266262
}),
267263
]),
268-
/**
269-
* Props applied to the transition element.
270-
* By default, the element is based on this [`Transition`](http://reactcommunity.org/react-transition-group/transition) component.
271-
*/
272-
TransitionProps: PropTypes.object,
273264
/**
274265
* The variant to use. Use `menu` to prevent selected items from impacting the initial focus
275266
* and the vertical alignment relative to the anchor element.

packages/material-ui/src/Menu/Menu.test.js

Lines changed: 1 addition & 119 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import * as React from 'react';
2-
import * as PropTypes from 'prop-types';
3-
import { spy, stub } from 'sinon';
2+
import { spy } from 'sinon';
43
import { expect } from 'chai';
54
import { getClasses } from '@material-ui/core/test-utils';
65
import createMount from 'test/utils/createMount';
@@ -38,15 +37,6 @@ describe('<Menu />', () => {
3837
}));
3938

4039
describe('event callbacks', () => {
41-
beforeEach(() => {
42-
PropTypes.resetWarningCache();
43-
stub(console, 'error');
44-
});
45-
46-
afterEach(() => {
47-
console.error.restore();
48-
});
49-
5040
describe('entering', () => {
5141
it('should fire callbacks', (done) => {
5242
const handleEnter = spy();
@@ -103,114 +93,6 @@ describe('<Menu />', () => {
10393
});
10494
});
10595
});
106-
107-
describe('prop: onEnter', () => {
108-
it('issues a warning', () => {
109-
PropTypes.checkPropTypes(
110-
Menu.Naked.propTypes,
111-
{
112-
onEnter: () => [],
113-
},
114-
'prop',
115-
'Menu',
116-
);
117-
118-
expect(console.error.callCount).to.equal(2);
119-
expect(console.error.firstCall.args[0]).to.equal(
120-
'Warning: Failed prop type: The prop `onEnter` of `Menu` is deprecated. Use the `TransitionProps` prop instead.',
121-
);
122-
});
123-
});
124-
125-
describe('prop: onEntering', () => {
126-
it('issues a warning', () => {
127-
PropTypes.checkPropTypes(
128-
Menu.Naked.propTypes,
129-
{
130-
onEntering: () => [],
131-
},
132-
'prop',
133-
'Menu',
134-
);
135-
136-
expect(console.error.callCount).to.equal(2);
137-
expect(console.error.firstCall.args[0]).to.equal(
138-
'Warning: Failed prop type: The prop `onEntering` of `Menu` is deprecated. Use the `TransitionProps` prop instead.',
139-
);
140-
});
141-
});
142-
143-
describe('prop: onEntered', () => {
144-
it('issues a warning', () => {
145-
PropTypes.checkPropTypes(
146-
Menu.Naked.propTypes,
147-
{
148-
onEntered: () => [],
149-
},
150-
'prop',
151-
'Menu',
152-
);
153-
154-
expect(console.error.callCount).to.equal(2);
155-
expect(console.error.firstCall.args[0]).to.equal(
156-
'Warning: Failed prop type: The prop `onEntered` of `Menu` is deprecated. Use the `TransitionProps` prop instead.',
157-
);
158-
});
159-
});
160-
161-
describe('prop: onExit', () => {
162-
it('issues a warning', () => {
163-
PropTypes.checkPropTypes(
164-
Menu.Naked.propTypes,
165-
{
166-
onExit: () => [],
167-
},
168-
'prop',
169-
'Menu',
170-
);
171-
172-
expect(console.error.callCount).to.equal(2);
173-
expect(console.error.firstCall.args[0]).to.equal(
174-
'Warning: Failed prop type: The prop `onExit` of `Menu` is deprecated. Use the `TransitionProps` prop instead.',
175-
);
176-
});
177-
});
178-
179-
describe('prop: onExiting', () => {
180-
it('issues a warning', () => {
181-
PropTypes.checkPropTypes(
182-
Menu.Naked.propTypes,
183-
{
184-
onExiting: () => [],
185-
},
186-
'prop',
187-
'Menu',
188-
);
189-
190-
expect(console.error.callCount).to.equal(2);
191-
expect(console.error.firstCall.args[0]).to.equal(
192-
'Warning: Failed prop type: The prop `onExiting` of `Menu` is deprecated. Use the `TransitionProps` prop instead.',
193-
);
194-
});
195-
});
196-
197-
describe('prop: onExited', () => {
198-
it('issues a warning', () => {
199-
PropTypes.checkPropTypes(
200-
Menu.Naked.propTypes,
201-
{
202-
onExited: () => [],
203-
},
204-
'prop',
205-
'Menu',
206-
);
207-
208-
expect(console.error.callCount).to.equal(2);
209-
expect(console.error.firstCall.args[0]).to.equal(
210-
'Warning: Failed prop type: The prop `onExited` of `Menu` is deprecated. Use the `TransitionProps` prop instead.',
211-
);
212-
});
213-
});
21496
});
21597

21698
it('should pass `classes.paper` to the Popover', () => {

0 commit comments

Comments
 (0)