Skip to content
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

MUI Dialog - React does not recognize the anchorPosition prop on a DOM element. #118

Closed
mightym opened this issue Mar 19, 2023 · 8 comments
Labels

Comments

@mightym
Copy link

mightym commented Mar 19, 2023

I'm using material-ui-popup-state on a MUI Dialog. And I'm getting those warnings:

Warning: React does not recognize the `anchorEl` prop on a DOM element. If you intentionally want it to appear in the DOM as a custom attribute, spell it as lowercase `anchorel` instead. If you accidentally passed it from a parent component, remove it from the DOM element.

Warning: React does not recognize the `anchorPosition` prop on a DOM element. If you intentionally want it to appear in the DOM as a custom attribute, spell it as lowercase `anchorposition` instead. If you accidentally passed it from a parent component, remove it from the DOM element.

React does not recognize the `anchorReference` prop on a DOM element. If you intentionally want it to appear in the DOM as a custom attribute, spell it as lowercase `anchorreference` instead. If you accidentally passed it from a parent component, remove it from the DOM element

Is this something I can ignore or am I doing something wrong here?

@jedwards1211
Copy link
Member

jedwards1211 commented Mar 20, 2023

those are props for a Popover or Menu so you're probably passing the wrong props to the Dialog; make sure you're passing variant: 'dialog' to usePopupState() and passing {...bindDialog(popupState)} props to the <Dialog>. If that still doesn't work I'll need to see the code to tell what's going wrong.

@mightym
Copy link
Author

mightym commented Mar 20, 2023

This is my popupState and the according render function:

const popupState = usePopupState({
   variant: 'dialog',
   popupId: 'settingsDialog',
});

return (
  <SettingsDialog
     popupState={popupState}
  />
);

and this my Dialog Component:

export const SettingsDialog = ({
  popupState,
}) => {
  return (
    <Dialog
      {...bindMenu(popupState)}
    >
      <DialogTitle onClose={popupState.close}>
        Settings
      </DialogTitle>
    </Dialog>
  )
};

@mightym
Copy link
Author

mightym commented Mar 20, 2023

Oh I just realize there is another Warning/Error:

[material-ui-popup-state] WARNING – "eventOrAnchorEl should be defined if setAnchorEl is not used" printWarning — react-dom.development.js:86

Maybe I'm doing something wrong there...

@jedwards1211
Copy link
Member

Here's what to do

    <Dialog
-      {...bindMenu(popupState)}
+      {...bindDialog(popupState)}
    >

@mightym
Copy link
Author

mightym commented Mar 20, 2023

Oh @jedwards1211 ... thanks a lot :)

@mightym
Copy link
Author

mightym commented Mar 20, 2023

@jedwards1211 and the error about

[material-ui-popup-state] WARNING – "eventOrAnchorEl should be defined if setAnchorEl is not used"

can be ignored or do I need to set eventOrAnchorEl ?

@jedwards1211
Copy link
Member

Oh thanks for asking, looking at the code, I need to prevent it from warning about that when variant: 'dialog' is used.

@jedwards1211
Copy link
Member

🎉 This issue has been resolved in version 5.0.7 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants