add}
+ slotProps={{ tooltip: { open: true, placement, title: 'placeholder' } }}
+ />,
+ );
+
+ expect(container.querySelector(`.${classes.staticTooltip}`)).to.have.class(
+ classes[className],
+ );
+ });
+ });
+
+ describe.skipIf(isJsdom())('static tooltip label layout', () => {
+ function center(rect, axis) {
+ return axis === 'x' ? rect.left + rect.width / 2 : rect.top + rect.height / 2;
+ }
+
+ [
+ ['top', 'x', (label, fab) => fab.top - label.bottom],
+ ['bottom', 'x', (label, fab) => label.top - fab.bottom],
+ ['left', 'y', (label, fab) => fab.left - label.right],
+ ['right', 'y', (label, fab) => label.left - fab.right],
+ ['top-start', 'x', (label, fab) => fab.top - label.bottom],
+ ['left-end', 'y', (label, fab) => fab.left - label.right],
+ ['auto', 'y', (label, fab) => fab.left - label.right],
+ ].forEach(([placement, axis, getGap]) => {
+ it(`places the label next to the Fab when placement is ${placement}`, () => {
+ // SpeedDial lays out its actions in a flex container.
+ const { container } = render(
+
+ add}
+ open
+ slotProps={{ tooltip: { open: true, placement, title: 'placeholder' } }}
+ />
+
,
+ );
+
+ const root = container.querySelector(`.${classes.staticTooltip}`).getBoundingClientRect();
+ const label = screen.getByText('placeholder').getBoundingClientRect();
+ const fab = screen.getByRole('menuitem').getBoundingClientRect();
+
+ // 8px margin on the label plus 8px margin on the Fab.
+ expect(Math.abs(getGap(label, fab) - 16)).to.be.lessThan(1);
+ expect(Math.abs(center(label, axis) - center(fab, axis))).to.be.lessThan(1);
+ // The label doesn't make the action taller.
+ expect(Math.abs(root.height - (fab.height + 16))).to.be.lessThan(1);
+ });
+ });
+ });
+
it('should have staticToolTip and staticToolTipLabel classes if slotProps.tooltip.open is true and custom slots are provided', () => {
const CustomStaticTooltip = React.forwardRef(({ ownerState, ...props }, ref) => (
diff --git a/packages/mui-material/src/SpeedDialAction/speedDialActionClasses.ts b/packages/mui-material/src/SpeedDialAction/speedDialActionClasses.ts
index 500cb4d75c6d29..680b36a56e51aa 100644
--- a/packages/mui-material/src/SpeedDialAction/speedDialActionClasses.ts
+++ b/packages/mui-material/src/SpeedDialAction/speedDialActionClasses.ts
@@ -6,16 +6,20 @@ export interface SpeedDialActionClasses {
fab: string;
/** Styles applied to the Fab component if `open={false}`. */
fabClosed: string;
- /** Styles applied to the root element if `tooltipOpen={true}`. */
+ /** Styles applied to the root element if `slotProps.tooltip.open` is `true`. */
staticTooltip: string;
- /** Styles applied to the root element if `tooltipOpen={true}` and `open={false}`. */
+ /** Styles applied to the root element if `slotProps.tooltip.open` is `true` and `open` is `false`. */
staticTooltipClosed: string;
- /** Styles applied to the static tooltip label if `tooltipOpen={true}`. */
+ /** Styles applied to the static tooltip label if `slotProps.tooltip.open` is `true`. */
staticTooltipLabel: string;
- /** Styles applied to the root element if `tooltipOpen={true}` and `tooltipPlacement="left"`` */
+ /** Styles applied to the root element if `slotProps.tooltip.open` is `true` and `slotProps.tooltip.placement` contains "left". */
tooltipPlacementLeft: string;
- /** Styles applied to the root element if `tooltipOpen={true}` and `tooltipPlacement="right"`` */
+ /** Styles applied to the root element if `slotProps.tooltip.open` is `true` and `slotProps.tooltip.placement` contains "right". */
tooltipPlacementRight: string;
+ /** Styles applied to the root element if `slotProps.tooltip.open` is `true` and `slotProps.tooltip.placement` contains "top". */
+ tooltipPlacementTop: string;
+ /** Styles applied to the root element if `slotProps.tooltip.open` is `true` and `slotProps.tooltip.placement` contains "bottom". */
+ tooltipPlacementBottom: string;
}
export type SpeedDialActionClassKey = keyof SpeedDialActionClasses;
@@ -34,6 +38,8 @@ const speedDialActionClasses: SpeedDialActionClasses = generateUtilityClasses(
'staticTooltipLabel',
'tooltipPlacementLeft',
'tooltipPlacementRight',
+ 'tooltipPlacementTop',
+ 'tooltipPlacementBottom',
],
);
diff --git a/test/regressions/fixtures/SpeedDial/Directions.js b/test/regressions/fixtures/SpeedDial/Directions.js
index 84b5eeed054e56..06f621894e78d5 100644
--- a/test/regressions/fixtures/SpeedDial/Directions.js
+++ b/test/regressions/fixtures/SpeedDial/Directions.js
@@ -39,13 +39,15 @@ SimpleSpeedDial.propTypes = {
function Directions() {
return (
-
- {['up', 'down'].map((direction) => (
+
+ {['up', 'down', 'left', 'right'].map((direction) => (