Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Respect CSS zoom #5772

Merged
merged 4 commits into from
Mar 28, 2024
Merged

Respect CSS zoom #5772

merged 4 commits into from
Mar 28, 2024

Conversation

ebads67
Copy link
Collaborator

@ebads67 ebads67 commented Mar 27, 2024

Css zoom property affects the mouse position in events. However, functions like getBoundingClientRect do not care about the css zoom. Hence, the calculations that use mouse positions and getBoundingClientRect return wrong values. In this PR those calculations are fixed to return the correct value when css zoom property is used.

Css zoom has only been implemented in Nightly version of Firefox. So the fix does not apply to Firefox.

In all the examples below the css zoom property is set to 2 on the body of the document..

Issue with checklist interactions:
checklist-zoom
Issue with drag handle:
drag-handle-zoom
Issue with context menu:
context-menu-zoom

Copy link

vercel bot commented Mar 27, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
lexical ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 28, 2024 10:06am
lexical-playground ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 28, 2024 10:06am

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Mar 27, 2024
@ebads67 ebads67 marked this pull request as ready for review March 27, 2024 20:10
@ivailop7
Copy link
Collaborator

Looking very good! Thanks for fixing! Integrity fails because of prettier formatting.

Copy link
Collaborator

@ivailop7 ivailop7 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fantastic fix!

@ivailop7 ivailop7 changed the title Respect css zoom Respect CSS zoom Mar 28, 2024
@ebads67 ebads67 merged commit 3ac5836 into facebook:main Mar 28, 2024
44 of 45 checks passed
* @param element
*/
export function calculateZoomLevel(element: Element | null): number {
if (IS_FIREFOX) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this do feature detection rather than browser detection?

@Daniel15
Copy link
Member

Daniel15 commented Apr 1, 2024

Css zoom has only been implemented in Nightly version of Firefox.

Interesting, I didn't realise they finally implemented it. The bug tracking its implementation is 17 years old: https://bugzilla.mozilla.org/show_bug.cgi?id=390936

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants