Open bjovanovic123 opened 5 months ago
I reproduced the bug and I confirm the issue. when you remove the direction="right" it works but when I added the direction="right", Speed Dial Actions are over Tooltips, covering them
Thanks for reporting. It's a bug. Would you like to create a PR?
Hello! Of course I would like to work on this issue
hello again! While reviewing the code of @bjovanovic123, I may have the suggestion that will solve this issue. To ensure that the tooltips are displayed correctly above or below the action buttons in the SpeedDial component when the direction is horizontal (direction="right" or direction="left"), we can adjust the tooltipPlacement dynamically based on the direction of the SpeedDial. Here is a suggestion of how the code would look like:
import React, {useState} as React from "react";
import Box from "@mui/material/Box";
import Backdrop from "@mui/material/Backdrop";
import SpeedDial from "@mui/material/SpeedDial";
import SpeedDialIcon from "@mui/material/SpeedDialIcon";
import SpeedDialAction from "@mui/material/SpeedDialAction";
import FileCopyIcon from "@mui/icons-material/FileCopyOutlined";
import SaveIcon from "@mui/icons-material/Save";
import PrintIcon from "@mui/icons-material/Print";
import ShareIcon from "@mui/icons-material/Share";
const actions = [
{ icon: <FileCopyIcon />, name: "Copy" },
{ icon: <SaveIcon />, name: "Save" },
{ icon: <PrintIcon />, name: "Print" },
{ icon: <ShareIcon />, name: "Share" },
];
export default function App() {
const [open, setOpen] = useState(false);
const [direction, setDirection] = useState("right");
const handleOpen = () => setOpen(true);
const handleClose = () => setOpen(false);
const handleDirectionChange = (newDirection) => {
setDirection(newDirection);
};
return (
<Box sx={{ height: 330, transform: "translateZ(0px)", flexGrow: 1 }}>
<Backdrop open={open} />
<SpeedDial
ariaLabel="SpeedDial tooltip example"
sx={{ position: "absolute", bottom: 16, right: 16 }}
icon={<SpeedDialIcon />}
onClose={handleClose}
onOpen={handleOpen}
open={open}
direction={direction}
onDirectionChange={handleDirectionChange}
>
{actions.map((action) => (
<SpeedDialAction
key={action.name}
icon={action.icon}
tooltipTitle={action.name}
tooltipOpen={open && direction === "down"}
tooltipPlacement={direction === "right" || direction === "left" ? "top" : "left"}
onClick={handleClose}
/>
))}
</SpeedDial>
</Box>
);
}
@EyaOuenniche Even with tooltipPlacement set to top
or bottom
, it doesn't behave as expected. Additionally, the Speed Dial component does not have onDirectionChange
prop.
I was blocked for one of my feature developments. So, I fixed the issue in this PR here faster. @EyaOuenniche, my apologies for intervening and taking over the task. I needed to resolve it to continue progress on my work faster. Feel free to decline, if you have a better solution. 🙏🏽
Steps to reproduce
Link to live example: https://codesandbox.io/p/sandbox/sad-voice-hnlnfk?file=%2Fsrc%2FDemo.js%3A41%2C24
Steps:
Current behavior
Speed Dial Actions are over Tooltips, covering them, and don't look good:![SpeedDial bug](https://github.com/mui/material-ui/assets/60741741/03fd728b-fd49-421d-8036-dbde7b9531e9)
Expected behavior
Tooltips should be visible and styled correctly when the direction is horizontal.
With SpeedDial
direction="right"
ordirection="left"
, Tooltips should be placed on top or bottom of action buttons. I've tried passingtooltipPlacement="top"
to SpeedDialAction, but it doesn't workContext
No response
Your environment
Search keywords: This issue has not been reported