diff --git a/packages/material-ui/src/Popper/Popper.js b/packages/material-ui/src/Popper/Popper.js index 440aa8f1f24979..77b0c5ab9e83fd 100644 --- a/packages/material-ui/src/Popper/Popper.js +++ b/packages/material-ui/src/Popper/Popper.js @@ -4,7 +4,6 @@ import { createPopper } from '@popperjs/core'; import { chainPropTypes, refType, HTMLElementType } from '@material-ui/utils'; import { useTheme } from '@material-ui/styles'; import Portal from '../Portal'; -import createChainedFunction from '../utils/createChainedFunction'; import setRef from '../utils/setRef'; import useForkRef from '../utils/useForkRef'; @@ -139,7 +138,7 @@ const Popper = React.forwardRef(function Popper(props, ref) { enabled: true, phase: 'afterWrite', fn({ state }) { - createChainedFunction(handlePopperUpdate, popperOptions.onUpdate)(state); + handlePopperUpdate(state); }, }, ]; @@ -155,9 +154,6 @@ const Popper = React.forwardRef(function Popper(props, ref) { placement: rtlPlacement, ...popperOptions, modifiers: popperModifiers, - // We could have been using a custom modifier like react-popper is doing. - // But it seems this is the best public API for this use case. - onFirstUpdate: createChainedFunction(handlePopperUpdate, popperOptions.onFirstUpdate), }); handlePopperRefRef.current(popper); diff --git a/packages/material-ui/src/Popper/Popper.test.js b/packages/material-ui/src/Popper/Popper.test.js index 24449784fbd75a..d40abc10efdaed 100644 --- a/packages/material-ui/src/Popper/Popper.test.js +++ b/packages/material-ui/src/Popper/Popper.test.js @@ -110,14 +110,7 @@ describe('', () => { ); expect(renderSpy.args).to.deep.equal([['bottom'], ['bottom']]); await popperRef.current.setOptions({ placement: 'top' }); - expect(renderSpy.args).to.deep.equal([ - ['bottom'], - ['bottom'], - ['top'], - ['top'], - ['top'], - ['top'], - ]); + expect(renderSpy.args).to.deep.equal([['bottom'], ['bottom'], ['top'], ['top']]); }); }); @@ -140,16 +133,21 @@ describe('', () => { }); describe('prop: popperOptions', () => { - it('should pass all popperOptions to popperjs', (done) => { - const popperOptions = { - onCreate: (data) => { - data.instance.update({ placement: 'left' }); - }, - onUpdate: () => { - done(); - }, - }; - render(); + it('should pass all popperOptions to popperjs', () => { + const popperRef = React.createRef(); + render( + , + ); + + expect(popperRef.current.state.placement).to.equal('bottom'); }); });