Bugfix: Keep toggle switch X icon centered at all browser zoom levels - #2572
Bugfix: Keep toggle switch X icon centered at all browser zoom levels#2572az108 wants to merge 7 commits into
Bugfix: Keep toggle switch X icon centered at all browser zoom levels#2572Conversation
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Up to standards ✅🟢 Issues
|
|
There hasn't been any activity on this pull request recently. Therefore, this pull request has been automatically marked as stale and will be closed if no further activity occurs within seven days. Thank you for your contributions. |
|
There hasn't been any activity on this pull request recently. Therefore, this pull request has been automatically marked as stale and will be closed if no further activity occurs within seven days. Thank you for your contributions. |
|
There hasn't been any activity on this pull request recently. Therefore, this pull request has been automatically marked as stale and will be closed if no further activity occurs within seven days. Thank you for your contributions. |
Flex centering left the icon with ~1px of vertical slack inside the short elliptical handle; the browser snapped that slack to whole device pixels inconsistently across zoom levels, so the icon drifted vertically. Absolute positioning with translate(-50%, -50%) centers in a single step with no margin rounding, keeping the icon centered at all zoom levels. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
There hasn't been any activity on this pull request recently. Therefore, this pull request has been automatically marked as stale and will be closed if no further activity occurs within seven days. Thank you for your contributions. |
|
There hasn't been any activity on this pull request recently. Therefore, this pull request has been automatically marked as stale and will be closed if no further activity occurs within seven days. Thank you for your contributions. |
|
There hasn't been any activity on this pull request recently. Therefore, this pull request has been automatically marked as stale and will be closed if no further activity occurs within seven days. Thank you for your contributions. |

Checklist
General
Client
Motivation and Context
Closes #2569.
The X icon inside the toggle switch handle drifted off-center at non-100% browser zoom levels (60%, 80%, 120%, 150%). At 100% the icon looked roughly centered, but at other zoom levels it sat noticeably above or below the visual centre of the handle, making the component feel unpolished.
Description
The handle (
.p-toggleswitch-handle) was alreadyflex items-center justify-center, so flex centering was wired up correctly. The drift came from<fa-icon>itself rendering as inline content: its bounding box included font-baseline metrics from the line box, and at non-integer zoom factors the browser's sub-pixel rounding aligned that baseline-derived box differently in the vertical axis than the horizontal axis. The result was a visible vertical shift that changed with zoom.The fix removes the baseline geometry from the chain:
<fa-icon>itself a flex container (flex items-center justify-center) so its inner SVG is centred geometrically inside it instead of via inline-text alignment.<svg>block([&>svg]:block) so it is no longer subject to baseline alignment within thefa-iconwrapper.With both inline-baseline alignments removed, centering depends only on flexbox geometry, which is stable across zoom levels.
No test was added: the change is purely about visual centering at fractional zoom levels, which jsdom cannot meaningfully assert. The behaviour is verified manually per the steps below.
Steps for Testing
Prerequisites:
Review Progress
Code Review
Manual Tests
Screenshots
To be added by the reviewer after manual verification across zoom levels.