astryx icon indicating copy to clipboard operation
astryx copied to clipboard

[Bug] Button scale animation at 1.25 dpr causes text inside to shift based on button position

Open muratkerimaslan opened this issue 5 days ago • 3 comments

Description

@astryxdesign/core v0.7.17 · Button

If the browser screen has 1.25 devicePixelRatio, the scaling animation on button click also shifts the content by 1px .

Example of the shift in 1.25 dpr scren: Zoomed in using the laptop touchpad to show the exaggerated version of the shift. https://github.com/user-attachments/assets/c2abdb30-8e66-41ea-ab9b-015159502060

Same test, but zoomed the chrome out to 80% to make my screen dpr equal to 1. The shift is non-existent

https://github.com/user-attachments/assets/8eddb08a-868f-4024-90d9-a780bf56b5e2

Reproduction

  1. make sure your browser window has 1.25 devicePixelRatio
  2. go to https://astryx.atmeta.com/components/Button and click the buttons.
  3. If the text shift is not visible, try to move the button by a few pixels in X and Y direction. (try 1px, 2px,3px,4px )

Astryx Version

@astryxdesign/core v0.7.17

Environment

Chrome 158, Windows 11, 1920x1080p screen with 125% scale Windows (recommended display settings by the OS)

muratkerimaslan avatar Nov 30 '26 12:11 muratkerimaslan

🤖 (Posted by Cindy's agent.) Thanks for the clear report and the side-by-side recordings, @muratkerimaslan! A press animation that makes a button's text jump by a pixel depending on where the button sits is a real visual bug, and the fact that it disappears at 1× scaling is a useful clue. We'll reproduce it at 125% display scaling in Chrome on Windows and follow up here with what we find.

cixzhang avatar Nov 30 '26 15:11 cixzhang

Confirmed and found the cause: Chromium promotes Button to a composited layer only during the :active scale transition, which changes text pixel-snapping from global to layer-local coordinates. At 1.25 DPR (100% zoom), the default md button's 6px vertical label offset lands on 7.5 physical px (an exact .5 rounding tie), causing the 1px shift on click. Working on a fix with will-change: transform scoped to fractional DPRs.

Geervan avatar Nov 30 '26 15:11 Geervan

🤖 (Posted by Cindy's agent.) Thanks for the clear report and the side-by-side recordings, @muratkerimaslan! A press animation that makes a button's text jump by a pixel depending on where the button sits is a real visual bug, and the fact that it disappears at 1× scaling is a useful clue. We'll reproduce it at 125% display scaling in Chrome on Windows and follow up here with what we find.

Hi, I'd like to take this one. I'll reproduce the 1px text shift on Button press at 1.25 DPR, find the rounding cause in the press scale animation, and add a regression test.

ravindrasinghshah avatar Nov 30 '26 15:11 ravindrasinghshah