diff --git a/docs/src/pages/components/slider/CustomizedSlider.js b/docs/src/pages/components/slider/CustomizedSlider.js index 2b5ebc29748b04..e8e017eb48172e 100644 --- a/docs/src/pages/components/slider/CustomizedSlider.js +++ b/docs/src/pages/components/slider/CustomizedSlider.js @@ -17,23 +17,8 @@ const useStyles = makeStyles(theme => ({ function ValueLabelComponent(props) { const { children, open, value } = props; - const popperRef = React.useRef(null); - React.useEffect(() => { - if (popperRef.current) { - popperRef.current.update(); - } - }); - return ( - + {children} ); diff --git a/docs/src/pages/components/slider/CustomizedSlider.tsx b/docs/src/pages/components/slider/CustomizedSlider.tsx index 887a4459cbc7ef..cfaafa287fa497 100644 --- a/docs/src/pages/components/slider/CustomizedSlider.tsx +++ b/docs/src/pages/components/slider/CustomizedSlider.tsx @@ -3,7 +3,6 @@ import { withStyles, makeStyles, Theme, createStyles } from '@material-ui/core/s import Slider from '@material-ui/core/Slider'; import Typography from '@material-ui/core/Typography'; import Tooltip from '@material-ui/core/Tooltip'; -import PopperJs from 'popper.js'; const useStyles = makeStyles((theme: Theme) => createStyles({ @@ -25,23 +24,8 @@ interface Props { function ValueLabelComponent(props: Props) { const { children, open, value } = props; - const popperRef = React.useRef(null); - React.useEffect(() => { - if (popperRef.current) { - popperRef.current.update(); - } - }); - return ( - + {children} ); diff --git a/packages/material-ui-lab/src/Autocomplete/Autocomplete.d.ts b/packages/material-ui-lab/src/Autocomplete/Autocomplete.d.ts index a9f379eaf47472..39cf759bc82fd8 100644 --- a/packages/material-ui-lab/src/Autocomplete/Autocomplete.d.ts +++ b/packages/material-ui-lab/src/Autocomplete/Autocomplete.d.ts @@ -1,15 +1,10 @@ import * as React from 'react'; import { StandardProps } from '@material-ui/core'; +import { PopperProps } from '@material-ui/core/Popper'; import { UseAutocompleteProps, CreateFilterOptions, createFilterOptions } from '../useAutocomplete'; export { createFilterOptions }; -export interface PopperProps extends React.HTMLAttributes { - anchorEl?: HTMLElement; - open: boolean; - popperRef: React.Ref; -} - export interface RenderOptionState { inputValue: string; selected: boolean; diff --git a/packages/material-ui-lab/src/Autocomplete/Autocomplete.js b/packages/material-ui-lab/src/Autocomplete/Autocomplete.js index d6f1d1a5a1a313..a176bf81c01b23 100644 --- a/packages/material-ui-lab/src/Autocomplete/Autocomplete.js +++ b/packages/material-ui-lab/src/Autocomplete/Autocomplete.js @@ -208,7 +208,7 @@ export const styles = theme => ({ function DisablePortal(props) { // eslint-disable-next-line react/prop-types - const { popperRef, anchorEl, open, ...other } = props; + const { anchorEl, open, ...other } = props; return
; } @@ -267,12 +267,6 @@ const Autocomplete = React.forwardRef(function Autocomplete(props, ref) { } = props; /* eslint-enable no-unused-vars */ - const popperRef = React.useRef(null); - React.useEffect(() => { - if (popperRef.current) { - popperRef.current.update(); - } - }); const PopperComponent = disablePortal ? DisablePortal : PopperComponentProp; const { @@ -412,7 +406,6 @@ const Autocomplete = React.forwardRef(function Autocomplete(props, ref) { width: anchorEl ? anchorEl.clientWidth : null, }} role="presentation" - popperRef={popperRef} anchorEl={anchorEl} open > diff --git a/packages/material-ui/src/Popper/Popper.js b/packages/material-ui/src/Popper/Popper.js index d2542f49c19e63..3775e0441ff8da 100644 --- a/packages/material-ui/src/Popper/Popper.js +++ b/packages/material-ui/src/Popper/Popper.js @@ -77,6 +77,12 @@ const Popper = React.forwardRef(function Popper(props, ref) { */ const [placement, setPlacement] = React.useState(rtlPlacement); + React.useEffect(() => { + if (popperRef.current) { + popperRef.current.update(); + } + }); + const handleOpen = React.useCallback(() => { if (!tooltipRef.current || !anchorEl || !open) { return;