mui / mui/material-ui

Popover is misaligned on fractional pixels

Open
#46,313 3 comments 0 reactions 1 assignee View on GitHub

@DiegoAndai is already working on this.

Since Jun 11, 2025.

breaking change component: Popover scope: popup type: enhancement waiting for 👍
Dominant language
JavaScript
Stars
99.1k
Forks
32.5k
Avg merge
2d 17h
Merged PRs (30d)
106

Description

Steps to reproduce

Steps:

  1. Open this link to live example: https://stackblitz.com/edit/github-tt94w8is?file=src%2FApp.tsx
    • Type in the textfield to see the popover, press "Esc" to hide it (also hides on blur).
  2. You'll need to zoom to a different level to see the misalignment problem - usually 150% or 125%. See the screenshot below for what I'm referring to. The popover becomes misaligned when fractions of a pixel are at play, usually this occurs when zoomed in.
  3. Type in the textfield and the popover will pop-up and be misaligned by a fraction of a pixel (side note: if you zoom with the popover it becomes misaligned, but this is not what I'm referring to).
  4. It seems that MUI rounds the left and top positions (https://github.com/mui/material-ui/blob/master/packages/mui-material/src/Popover/Popover.js#L279), thus fractional pixels sometimes cause misalignment. This leads to a "broken" effect when popovers are connecting to other UI elements.
    Example of the problem:
    Image

The popover is misaligned by a fraction of a pixel. I believe this is due to the rounding that occurs in the popover element.

Current behavior

Currently MUI round the top and left positions, thus the popover snaps to the pixel grid rather than being directly aligned with the element its supposed to align with.

Expected behavior

The popover should align with the element its suppose to align with, even if fractional pixels are at play.

Context

I'm creating a search suggestion component.

Your environment
npx @mui/envinfo
  System:
    OS: Linux 4.18 Red Hat Enterprise Linux 8.10 (Ootpa)
  Binaries:
    Node: 20.19.0 - ~/.nvm/versions/node/v20.19.0/bin/node
    npm: 10.8.2 - ~/.nvm/versions/node/v20.19.0/bin/npm
    pnpm: Not Found
  Browsers:
    Chrome: Not Found
  npmPackages:
    @emotion/react: ^11.11.4 => 11.11.4 
    @emotion/styled: ^11.11.5 => 11.11.5 
    @mui/base: ^5.0.0-beta.48 => 5.0.0-beta.61 
    @mui/core-downloads-tracker:  6.1.6 
    @mui/icons-material: 6.1.6 => 6.1.6 
    @mui/lab: 6.0.0-beta.14 => 6.0.0-beta.14 
    @mui/material: 6.1.6 => 6.1.6 
    @mui/private-theming: ^5.15.14 => 5.15.14 
    @mui/styled-engine:  6.1.6 
    @mui/system: 6.1.6 => 6.1.6 
    @mui/types:  7.2.19 
    @mui/utils: 6.1.6 => 6.1.6 
    @mui/x-data-grid: ^7.14.0 => 7.16.0 
    @mui/x-date-pickers: ^7.22.1 => 7.22.1 
    @mui/x-internals:  7.15.0 
    @mui/x-tree-view:  7.15.0 
    @types/react:  18.3.3 
    react: ^18.1.0 => 18.2.0 
    react-dom: ^18.1.0 => 18.2.0 
    typescript:  4.9.5 

I'm using Chrome (Version 126.0.6478.182 (Official Build) (64-bit))

Search keywords: fractional, zoom

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.