Dzień dobry, podczas debugowania aplikacji webowej wyświetla mi się poniższy problem:
MUI: The `anchorEl` prop provided to the component is invalid.
The anchor element should be part of the document layout.
Make sure the element is present in the document or that it's not display none.
A oto kod gdzie występuje element anchorEl:
import Popover from "@mui/material/Popover";
....
const [podpowiedzimie, setpodpowiedzimie] = React.useState(null);
...
const PokazPodpowiedzImie = (event) => {
setpodpowiedzimie(event.target);
};
....
<span style={{ display: "flex", alignItems: "center" }}>
<TextField
requireds="true"
id="outlined-required"
label="Imię"
value={imie}
onChange={Przypisz_Imie}
error={!!tekst_bledu_imie}
helperText={tekst_bledu_imie}
style={{ width: 420 }}
/>
<Popover
sx={{
pointerEvents: "none",
}}
open={otworzpodpowiedzimie}
anchorEl={podpowiedzimie}
anchorOrigin={{
vertical: "bottom",
horizontal: "left",
}}
transformOrigin={{
vertical: "top",
horizontal: "left",
}}
onClose={UkryjhPodpowiedzImie}
disableRestoreFocus
>
<Typography sx={{ p: 1 }}>
Przykład prawidłowej formy imienia: Jan .
</Typography>
</Popover>
<HelpIcon
color="primary"
sx={{ fontSize: 30 }}
style={{ marginLeft: "10px" }}
onMouseEnter={PokazPodpowiedzImie}
onMouseLeave={UkryjhPodpowiedzImie}
/>
</span>
Końcowy efekt działania jest poprawny, czyli po najechaniu na znak zapytania wyświetla się podpowiedź.
