-
-
Notifications
You must be signed in to change notification settings - Fork 32.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[docs] Popover/Chip demo runtime error #20175
Labels
bug 🐛
Something doesn't work
docs
Improvements or additions to the documentation
good first issue
Great for first contributions. Enable to learn the contribution process.
Comments
1 task
@adamdicarlo Thanks for reporting this problem. It's my fault, I was too eager in my changes in #20111. I would propose the following patch: do you want to work on it? :) diff --git a/docs/src/pages/components/chips/ChipsPlayground.js b/docs/src/pages/components/chips/ChipsPlayground.js
index cada04484..610cf1357 100644
--- a/docs/src/pages/components/chips/ChipsPlayground.js
+++ b/docs/src/pages/components/chips/ChipsPlayground.js
@@ -24,7 +24,7 @@ const styles = theme => ({
function ChipsPlayground(props) {
const { classes } = props;
- const [{ color, onDelete, avatar, icon, variant, size }, setState] = React.useState({
+ const [state, setState] = React.useState({
color: 'default',
onDelete: 'none',
avatar: 'none',
@@ -32,12 +32,13 @@ function ChipsPlayground(props) {
variant: 'default',
size: 'medium',
});
+ const { color, onDelete, avatar, icon, variant, size } = state;
const handleChange = event => {
- setState(state => ({
+ setState({
...state,
[event.target.name]: event.target.value,
- }));
+ });
};
const handleDeleteExample = () => {
diff --git a/docs/src/pages/components/popover/AnchorPlayground.js b/docs/src/pages/components/popover/AnchorPlayground.js
index d29b01ea0..56aee3a96 100644
--- a/docs/src/pages/components/popover/AnchorPlayground.js
+++ b/docs/src/pages/components/popover/AnchorPlayground.js
@@ -68,19 +68,7 @@ function AnchorPlayground(props) {
const { classes } = props;
const anchorRef = React.useRef();
- const [
- {
- open,
- anchorOriginVertical,
- anchorOriginHorizontal,
- transformOriginVertical,
- transformOriginHorizontal,
- positionTop,
- positionLeft,
- anchorReference,
- },
- setState,
- ] = React.useState({
+ const [state, setState] = React.useState({
open: false,
anchorOriginVertical: 'top',
anchorOriginHorizontal: 'left',
@@ -90,33 +78,43 @@ function AnchorPlayground(props) {
positionLeft: 400, // Same as above
anchorReference: 'anchorEl',
});
+ const {
+ open,
+ anchorOriginVertical,
+ anchorOriginHorizontal,
+ transformOriginVertical,
+ transformOriginHorizontal,
+ positionTop,
+ positionLeft,
+ anchorReference,
+ } = state;
const handleChange = event => {
- setState(state => ({
+ setState({
...state,
[event.target.name]: event.target.value,
- }));
+ });
};
const handleNumberInputChange = key => event => {
- setState(state => ({
+ setState({
...state,
[key]: parseInt(event.target.value, 10),
- }));
+ });
};
const handleClickButton = () => {
- setState(state => ({
+ setState({
...state,
open: true,
- }));
+ });
};
const handleClose = () => {
- setState(state => ({
+ setState({
...state,
open: false,
- }));
+ });
};
let mode = ''; |
oliviertassinari
added
bug 🐛
Something doesn't work
good first issue
Great for first contributions. Enable to learn the contribution process.
labels
Mar 19, 2020
oliviertassinari
changed the title
Popover demo runtime error (again?)
[docs] Popover/Chip demo runtime error
Mar 19, 2020
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
bug 🐛
Something doesn't work
docs
Improvements or additions to the documentation
good first issue
Great for first contributions. Enable to learn the contribution process.
The page at https://material-ui.com/components/popover/ has a demo that crashes when using the
anchorPosition.top
andanchorPosition.left
controls.Perhaps #17101 did not actually fix the bug.
Current Behavior 😯
Click either the down arrow or up arrow of either
anchorPositon.top
oranchorPosition.left
twice and the demo crashes with this message:Expected Behavior 🤔
I should be able to change those values more than once and the demo should never crash.
Steps to Reproduce 🕹
Your Environment 🌎
Firefox on macOS.
The text was updated successfully, but these errors were encountered: