-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Popper] Fix anchorEl prop types (#16004)
* Fix Popper's anchorEl prop type * make the visibility check work with referenceObject * better warning message * revert check visibility on referenceObject * refine the wording
- Loading branch information
1 parent
7199660
commit 41f1722
Showing
7 changed files
with
64 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import React from 'react'; | ||
import { makeStyles, Theme, createStyles } from '@material-ui/core/styles'; | ||
import Popper from '@material-ui/core/Popper'; | ||
import Typography from '@material-ui/core/Typography'; | ||
import Button from '@material-ui/core/Button'; | ||
import Fade from '@material-ui/core/Fade'; | ||
import Paper from '@material-ui/core/Paper'; | ||
|
||
const useStyles = makeStyles((theme: Theme) => | ||
createStyles({ | ||
typography: { | ||
padding: theme.spacing(2), | ||
}, | ||
}), | ||
); | ||
|
||
export default function SimplePopper() { | ||
const classes = useStyles(); | ||
const [anchorEl, setAnchorEl] = React.useState<null | HTMLElement>(null); | ||
|
||
function handleClick(event: React.MouseEvent<HTMLElement>) { | ||
setAnchorEl(anchorEl ? null : event.currentTarget); | ||
} | ||
|
||
const open = Boolean(anchorEl); | ||
const id = open ? 'simple-popper' : undefined; | ||
|
||
return ( | ||
<div> | ||
<Button aria-describedby={id} variant="contained" onClick={handleClick}> | ||
Toggle Popper | ||
</Button> | ||
<Popper id={id} open={open} anchorEl={anchorEl} transition> | ||
{({ TransitionProps }) => ( | ||
<Fade {...TransitionProps} timeout={350}> | ||
<Paper> | ||
<Typography className={classes.typography}>The content of the Popper.</Typography> | ||
</Paper> | ||
</Fade> | ||
)} | ||
</Popper> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters