Skip to content

Fix tooltip overflow - #1651

Merged
angrycat9000 merged 5 commits into
mainfrom
mark/tooltip-overflow
Jul 29, 2026
Merged

Fix tooltip overflow#1651
angrycat9000 merged 5 commits into
mainfrom
mark/tooltip-overflow

Conversation

@angrycat9000

@angrycat9000 angrycat9000 commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

Changes

Fixes #1644 by updating the popper preventOverflow and flip modifiers to include an extra 2px padding on each side to account for the expanded .MuiTooltip-tooltip::before element. See #1644 (comment)

Both flip and preventOverflow are needed to be adjusted, otherwise preventOverflow stops working 2px before flip kicks in and move the tooltip to the other side. During those 2px the scrollbar appears. Can see this by setting placement="right". and slowly shrinking the viewport.

Testing

  1. Change Tooltip.default.tsx to the following.
  2. Run docs and go to http://localhost:4321/docs/examples/mui/Tooltip.default
  3. Size the window to 480px wide
  4. Hover over the icon and make sure a scrollbar does not appear with the tooltip.
import { Box, Container, IconButton, Tooltip } from "@mui/material";
import { Icon } from "@stratakit/mui";

import svgPlaceholder from "@stratakit/icons/placeholder.svg";

export default () => {
	return (
		<Container maxWidth="sm" sx={{ mt: 4, border: "1px solid #bbb", p: 2 }}>
			<Box
				style={{
					position: "relative",
					height: 140,
					display: "flex",
					alignItems: "center",
					justifyContent: "flex-end",
				}}
			>
				<Tooltip title="A normal tooltip that affects height">
					<IconButton aria-label="Search for something" onClick={() => {}}>
						<Icon href={svgPlaceholder} />
					</IconButton>
				</Tooltip>
			</Box>
		</Container>
	);
};

@angrycat9000
angrycat9000 marked this pull request as ready for review July 24, 2026 17:52
@angrycat9000
angrycat9000 requested a review from a team as a code owner July 24, 2026 17:52
@angrycat9000
angrycat9000 requested review from FlyersPh9 and mayank99 and removed request for a team July 24, 2026 17:52
Comment thread packages/mui/src/~createTheme.tsx
Comment thread packages/mui/src/~createTheme.tsx
Comment thread packages/mui/src/~createTheme.tsx
@angrycat9000

Copy link
Copy Markdown
Contributor Author

Bump @GerardasB can you take a review on this? Thanks

Comment thread .changeset/violet-toes-vanish.md Outdated
Co-authored-by: Mayank <9084735+mayank99@users.noreply.github.com>
@angrycat9000
angrycat9000 merged commit a0b8746 into main Jul 29, 2026
16 of 17 checks passed
@angrycat9000
angrycat9000 deleted the mark/tooltip-overflow branch July 29, 2026 22:23
@github-actions github-actions Bot mentioned this pull request Jul 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Tooltip affecting height/width of components

3 participants